NDDEM
Classes | Enumerations | Enumerator | Functions | Variables
Coarse-graining

Classes

class  CGPoint
 Data computed for a single coarse graining point. More...
 
struct  Field
 Contains Field informations. More...
 
struct  Data
 Data structure handling point data and contact data. More...
 
class  Coarsing
 Main Coarse graining class. More...
 

Enumerations

enum  TensorOrder { NONE =-1 , SCALAR =0 , VECTOR =1 , TENSOR =2 }
 
enum  FieldType { Defined , Particle , Fluctuation , Contact }
 
enum  AverageType { None , Final , Intermediate , Both }
 
enum  Pass {
  Pass1 =1 , Pass2 =2 , Pass3 =4 , Pass4 =8 ,
  Pass5 =16 , VelFluct =256 , RotFluct =512
}
 

Functions

double Volume (int d, double R)
 Compute a sphere volume in dimension D. More...
 
Pass operator| (Pass a, Pass b)
 
bool operator& (Pass a, Pass b)
 
 CGPoint::CGPoint (int dd, v1d loc)
 
 Data::Data ()
 
int Data::random_test (int N, int Ncf, int d, v2d box)
 Randomly fill the data structure. More...
 
int Data::compute_lpq (int d)
 Compute lpq from contact id's and atom locations. More...
 
int Data::periodic_atoms (int d, v2d bounds, int pbc, v1d Delta, bool omegainclude)
 Copy particles through the periodic boundary conditions. Should call clean_periodic_atoms() after the full coarse-graining computation has been performed to clean the added atoms. More...
 
int Data::clean_periodic_atoms ()
 Clean periodic atoms. More...
 
bool Data::check_field_availability (string name)
 
int Data::add_extra_field (int length, std::string name)
 
 Coarsing::Coarsing (int dd, v1i nnpt, v2d bbox, int T)
 
 Coarsing::~Coarsing ()
 
int Coarsing::get_id (string nm)
 Find field ID from field name. More...
 
struct FieldCoarsing::get_field (string nm)
 Find Field from name. More...
 
Pass Coarsing::set_flags (vector< string > s)
 Set the fields which are requested from the coarse-graining. More...
 
int Coarsing::set_field_struct ()
 Set the FIELDS structure, with all the different CG properties that can be computed. More...
 
int Coarsing::add_extra_field (string name, TensorOrder order, FieldType type)
 Used to add extra user-defined fields. More...
 
int Coarsing::setWindow (Windows win, double w, vector< bool > per={}, vector< int > boxes={}, vector< double > deltas={})
 Set the windowing function, calling the templated version. More...
 
template<Windows W>
int Coarsing::setWindow ()
 Set the windowing function. More...
 
template<Windows W>
int Coarsing::setWindow (double w)
 Set the windowing function. More...
 
template<Windows W>
int Coarsing::setWindow (double w, vector< bool > per, vector< int > boxes, vector< double > deltas)
 Set the windowing function for the LibLucyND_Periodic (special one...) More...
 
int Coarsing::grid_generate ()
 Generate the coarse-graining grid. More...
 
int Coarsing::grid_neighbour ()
 Generated neighbors in the coarse-graining grid. More...
 
std::map< std::string, size_t > Coarsing::grid_setfields ()
 Set the fields at each CG point. More...
 
vector< FieldTypeCoarsing::grid_getfields ()
 Extract fields from each CG point. More...
 
v2d Coarsing::get_bounds ()
 Extract the simulation boundaries. More...
 
CGPointCoarsing::reverseloop (string type)
 go through the table in reverse order of the dimensions (for the writing phase essentially) More...
 
int Coarsing::find_closest (int id)
 Find the closest CG point to a particle. More...
 
int Coarsing::find_closest_pq (int id)
 Find the closest CG point to a contact. More...
 
v1d Coarsing::interpolate_vel (int id, bool usetimeavg=false)
 Interpolate the velocity. More...
 
v1d Coarsing::interpolate_rot (int id, bool usetimeavg=false)
 Interpolate the angular velocity. More...
 
v1d Coarsing::interpolate_vel_nearest (int id, bool usetimeavg=false)
 Nearest neighbor interpolation for the velocity. More...
 
v1d Coarsing::interpolate_rot_nearest (int id, bool usetimeavg=false)
 Nearest neighbor interpolation for the angular velocity. More...
 
v1d Coarsing::interpolate_vel_trilinear (int id, bool usetimeavg)
 Tri-linear interpolation (only implemented in 3D, probably not too hard to implement in ND but annoying ...) More...
 
template<int D>
v1d Coarsing::interpolate_vel_multilinear (int id, bool usetimeavg)
 
int Coarsing::idx_FastFirst2SlowFirst (int n)
 Change array traversing order. More...
 
double Coarsing::normdiff (v1d a, v1d b)
 
int Coarsing::pass_1 ()
 convenience function to to the difference of 2 vectors. More...
 
int Coarsing::pass_2 (bool usetimeavg=false)
 Coarse-grain anything based on particles (not contacts) which needs fluctuating quantities (call the compute_fluc_ functions before) More...
 
int Coarsing::pass_3 ()
 Coarse-grain anything based on contact informations (no fluctuations). More...
 
int Coarsing::pass_4 ()
 Coarse-grain anything based on contact informations & fluctuations. More...
 
int Coarsing::pass_5 ()
 Calculation of derived quantities. More...
 
int Coarsing::compute_fluc_vel (bool usetimeavg=false)
 Velocity fluctuation computation. More...
 
int Coarsing::compute_fluc_rot (bool usetimeavg=false)
 Angular velocity fluctuation computation. More...
 
int Coarsing::mean_time (bool temporary=false)
 Perform a time average of the coarse-grained data. More...
 
int Coarsing::write_vtk (string sout)
 Write CG data as VTK. More...
 
int Coarsing::write_netCDF (string sout)
 
int Coarsing::write_NrrdIO (string path)
 Write CG data as NrrdIO file format. More...
 
int Coarsing::write_matlab (string path, bool squeeze=false)
 Write CG data as Matlab file. More...
 
int Coarsing::write_numpy (string path, bool squeeze=false)
 Write CG data as numpy files (.npy) ;. More...
 
int Coarsing::write_numpy_npy (string path, bool squeeze)
 
std::pair< size_t, uint8_t * > Coarsing::write_numpy_locbuffer (bool squeeze)
 
std::pair< size_t, uint8_t * > Coarsing::write_numpy_buffer (int id, bool squeeze)
 

Variables

v2d CGPoint::fields
 1st dimension is time, second are fields More...
 
v1d CGPoint::location
 Location of the coarse graining point. More...
 
vector< int > CGPoint::neighbors
 All the neighbors of the point given the window. 1st index is the point itself. More...
 
int CGPoint::d
 Dimension. More...
 
uint64_t Field::flag
 Flag for the given field. More...
 
string Field::name
 Name for the given field. More...
 
TensorOrder Field::type
 Tensorial order of the field: SCALAR, VECTOR or TENSOR. More...
 
FieldType Field::ftype
 Mainly used to identified the type of user defined fields. More...
 
Pass Field::passlevel
 Identify at which moment the field gets calculated. More...
 
int Field::datalocation = -1
 For extra fields, identify the location in the vector of extra data. More...
 
int Data::N = 0
 Number of particles. More...
 
double * Data::radius
 Particle radius. More...
 
double * Data::mass
 Particle masses. More...
 
double * Data::Imom
 Particle moment of inertia. More...
 
vector< double * > Data::pos
 Particle positions. More...
 
vector< double * > Data::vel
 Particle velocity. More...
 
vector< double * > Data::omega
 Particle angular velocity. More...
 
v2d Data::vel_fluc
 Fluctuating velocity. Should not be externally provided but calculated, using the function Coarsing::compute_fluc_vel() More...
 
v2d Data::rot_fluc
 Fluctuating angular velocity. Should not be externally provided but calculated, using the function Coarsing::compute_fluc_vel() More...
 
int Data::Ncf
 Number of contacts. More...
 
double * Data::id1
 Index of first particle in contact. More...
 
double * Data::id2
 Index of the second particle in contact. More...
 
vector< double * > Data::pospq
 Location of contact point. More...
 
vector< double * > Data::lpq
 Branch vector of the contact, use compute_lpq() to populate this. More...
 
vector< double * > Data::fpq
 Force at contact. More...
 
vector< double * > Data::mpq
 Moment of particle 1 on 2. More...
 
vector< double * > Data::mqp
 Moment of particle 2 on 1. More...
 
vector< double * > Data::extra
 
vector< std::tuple< std::string, int, int > > Data::extrafields
 
int Data::Nnonper =-1
 Used if additional particles are added as images through the periodic boundary conditions. More...
 
int Coarsing::d
 Number of dimensions. More...
 
int Coarsing::Npt
 Number of coarse graining points. More...
 
int Coarsing::Time
 Total timesteps. More...
 
int Coarsing::cT
 Current timestep. More...
 
double Coarsing::cutoff
 CG width, and cutoff. More...
 
vector< CGPointCoarsing::CGP
 List of Coarse Graining points. More...
 
vector< CGPoint > * Coarsing::CGPtemp = nullptr
 Temporary cgpoint list that can store temporal averages if needed. More...
 
vector< int > Coarsing::npt
 Number of points per dimension. More...
 
vector< int > Coarsing::nptcum
 Cumulated number of points per dimensions (usefull for quick finding of the closest CG for a grain) More...
 
v1d Coarsing::dx
 Distances between CG points. More...
 
v2d Coarsing::box
 CG point location. More...
 
LibBaseCoarsing::Window = nullptr
 
unsigned int Coarsing::flags
 

Pointer to the averaging window

More...
 
vector< string > Coarsing::Fields
 
vector< string > Coarsing::Fname
 Flagged field names. More...
 
vector< int > Coarsing::Fidx
 Where the fields is referenced in the fields vector in the CGPoint. -1 if not flagged. More...
 
vector< TensorOrderCoarsing::Ftype
 Flagged field types. More...
 
vector< struct FieldCoarsing::FIELDS
 All allowed fields (initialized in grid_getfields) More...
 
bool Coarsing::hasvelfluct =false
 
bool Coarsing::hasrotfluct =false
 
struct Data Coarsing::data
 Data storage. More...
 

Detailed Description

This modules handles the coarse graining in any number of dimensions, and has some neat features that are not that common even for 3D coarse graining.

In particular, the following fields can be requested, equation numbering is from Babic, Marijan. "Average balance equations for granular materials." International journal of engineering science 35.5 (1997): 523-548.:
"RHO" "SCALAR" Eq 36 Density
"I" "SCALAR" Eq 65 Moment of Inertia
"VAVG" "VECTOR" Eq 38 Average Velocity
"TC" "TENSOR" Eq 63 Contact stress
"TK" "TENSOR" Eq 62 Kinetic stress
"ROT" "VECTOR" Eq 64 Internal spin density
"MC" "TENSOR" Eq 67 Contact couple stress tensor
"MK" "TENSOR" Eq 66 Kinetic couple stress tensor
"mC" "VECTOR" Eq 68 spin supply from contacts
"EKT" "SCALAR" VAVG^2/2 Kinetic energy density of average velocity
"eKT" "SCALAR" Eq 69 Kinetic energy density of fluctuating motion
"EKR" "SCALAR" (W.K.W)/2, kin energy of avg rotational motion, W angular velocity vector, K moment of inertia tensor
"eKR" "SCALAR" Eq 70 Kin energy of fluctuating rotational motion
"qTC" "VECTOR" Eq 72
"qTK" "VECTOR" Eq 71
"qRC" "VECTOR" Eq 74
"qRK" "VECTOR" Eq 73
"zT" "SCALAR" Eq 75
"zR" "SCALAR" Eq 76

Enumeration Type Documentation

◆ AverageType

Enumerator
None 
Final 
Intermediate 
Both 

◆ FieldType

enum FieldType
Enumerator
Defined 
Particle 
Fluctuation 
Contact 

◆ Pass

enum Pass
Enumerator
Pass1 
Pass2 
Pass3 
Pass4 
Pass5 
VelFluct 
RotFluct 

◆ TensorOrder

Enumerator
NONE 
SCALAR 
VECTOR 
TENSOR 

Function Documentation

◆ add_extra_field() [1/2]

int Data::add_extra_field ( int  length,
std::string  name 
)
inline

◆ add_extra_field() [2/2]

int Coarsing::add_extra_field ( string  name,
TensorOrder  order,
FieldType  type 
)

Used to add extra user-defined fields.

◆ CGPoint()

CGPoint::CGPoint ( int  dd,
v1d  loc 
)
inline

◆ check_field_availability()

bool Data::check_field_availability ( string  name)

◆ clean_periodic_atoms()

int Data::clean_periodic_atoms ( )
inline

Clean periodic atoms.

◆ Coarsing()

Coarsing::Coarsing ( int  dd,
v1i  nnpt,
v2d  bbox,
int  T 
)
inline

◆ compute_fluc_rot()

int Coarsing::compute_fluc_rot ( bool  usetimeavg = false)

Angular velocity fluctuation computation.

◆ compute_fluc_vel()

int Coarsing::compute_fluc_vel ( bool  usetimeavg = false)

Velocity fluctuation computation.

◆ compute_lpq()

int Data::compute_lpq ( int  d)

Compute lpq from contact id's and atom locations.

◆ Data()

Data::Data ( )
inline

◆ find_closest()

int Coarsing::find_closest ( int  id)

Find the closest CG point to a particle.

◆ find_closest_pq()

int Coarsing::find_closest_pq ( int  id)

Find the closest CG point to a contact.

◆ get_bounds()

v2d Coarsing::get_bounds ( )

Extract the simulation boundaries.

◆ get_field()

struct Field * Coarsing::get_field ( string  nm)

Find Field from name.

◆ get_id()

int Coarsing::get_id ( string  nm)

Find field ID from field name.

◆ grid_generate()

int Coarsing::grid_generate ( )

Generate the coarse-graining grid.

◆ grid_getfields()

vector< FieldType > Coarsing::grid_getfields ( )

Extract fields from each CG point.

◆ grid_neighbour()

int Coarsing::grid_neighbour ( )

Generated neighbors in the coarse-graining grid.

◆ grid_setfields()

std::map< std::string, size_t > Coarsing::grid_setfields ( )

Set the fields at each CG point.

◆ idx_FastFirst2SlowFirst()

int Coarsing::idx_FastFirst2SlowFirst ( int  n)

Change array traversing order.

◆ interpolate_rot()

v1d Coarsing::interpolate_rot ( int  id,
bool  usetimeavg = false 
)
inline

Interpolate the angular velocity.

Todo:
Use something better to interpolate velocity than the nearest neighbor interpolation.

◆ interpolate_rot_nearest()

v1d Coarsing::interpolate_rot_nearest ( int  id,
bool  usetimeavg = false 
)

Nearest neighbor interpolation for the angular velocity.

◆ interpolate_vel()

v1d Coarsing::interpolate_vel ( int  id,
bool  usetimeavg = false 
)
inline

Interpolate the velocity.

Todo:
Use something better to interpolate velocity than the nearest neighbor interpolation.

◆ interpolate_vel_multilinear()

template<int D>
v1d Coarsing::interpolate_vel_multilinear ( int  id,
bool  usetimeavg 
)

◆ interpolate_vel_nearest()

v1d Coarsing::interpolate_vel_nearest ( int  id,
bool  usetimeavg = false 
)

Nearest neighbor interpolation for the velocity.

◆ interpolate_vel_trilinear()

v1d Coarsing::interpolate_vel_trilinear ( int  id,
bool  usetimeavg 
)

Tri-linear interpolation (only implemented in 3D, probably not too hard to implement in ND but annoying ...)

◆ mean_time()

int Coarsing::mean_time ( bool  temporary = false)

Perform a time average of the coarse-grained data.

◆ normdiff()

double Coarsing::normdiff ( v1d  a,
v1d  b 
)
inline

◆ operator&()

bool operator& ( Pass  a,
Pass  b 
)
inline

◆ operator|()

Pass operator| ( Pass  a,
Pass  b 
)
inline

◆ pass_1()

int Coarsing::pass_1 ( )

convenience function to to the difference of 2 vectors.

Coarse-grain anything based on particles (not contacts) which does not need fluctuating quantities

◆ pass_2()

int Coarsing::pass_2 ( bool  usetimeavg = false)

Coarse-grain anything based on particles (not contacts) which needs fluctuating quantities (call the compute_fluc_ functions before)

◆ pass_3()

int Coarsing::pass_3 ( )

Coarse-grain anything based on contact informations (no fluctuations).

◆ pass_4()

int Coarsing::pass_4 ( )

Coarse-grain anything based on contact informations & fluctuations.

◆ pass_5()

int Coarsing::pass_5 ( )

Calculation of derived quantities.

◆ periodic_atoms()

int Data::periodic_atoms ( int  d,
v2d  bounds,
int  pbc,
v1d  Delta,
bool  omegainclude 
)

Copy particles through the periodic boundary conditions. Should call clean_periodic_atoms() after the full coarse-graining computation has been performed to clean the added atoms.

◆ random_test()

int Data::random_test ( int  N,
int  Ncf,
int  d,
v2d  box 
)

Randomly fill the data structure.

◆ reverseloop()

CGPoint * Coarsing::reverseloop ( string  type)

go through the table in reverse order of the dimensions (for the writing phase essentially)

◆ set_field_struct()

int Coarsing::set_field_struct ( )

Set the FIELDS structure, with all the different CG properties that can be computed.

◆ set_flags()

Pass Coarsing::set_flags ( vector< string >  s)

Set the fields which are requested from the coarse-graining.

◆ setWindow() [1/4]

template<Windows W>
int Coarsing::setWindow

Set the windowing function.

◆ setWindow() [2/4]

template<Windows W>
int Coarsing::setWindow ( double  w)

Set the windowing function.

◆ setWindow() [3/4]

template<Windows W>
int Coarsing::setWindow ( double  w,
vector< bool >  per,
vector< int >  boxes,
vector< double >  deltas 
)

Set the windowing function for the LibLucyND_Periodic (special one...)

◆ setWindow() [4/4]

int Coarsing::setWindow ( Windows  win,
double  w,
vector< bool >  per = {},
vector< int >  boxes = {},
vector< double >  deltas = {} 
)

Set the windowing function, calling the templated version.

◆ Volume()

double Volume ( int  d,
double  R 
)

Compute a sphere volume in dimension D.

◆ write_matlab()

int Coarsing::write_matlab ( string  path,
bool  squeeze = false 
)

Write CG data as Matlab file.

◆ write_netCDF()

int Coarsing::write_netCDF ( string  sout)
Deprecated:
Write CG data as netCDF

◆ write_NrrdIO()

int Coarsing::write_NrrdIO ( string  path)

Write CG data as NrrdIO file format.

◆ write_numpy()

int Coarsing::write_numpy ( string  path,
bool  squeeze = false 
)

Write CG data as numpy files (.npy) ;.

◆ write_numpy_buffer()

std::pair< size_t, uint8_t * > Coarsing::write_numpy_buffer ( int  id,
bool  squeeze 
)

◆ write_numpy_locbuffer()

std::pair<size_t, uint8_t*> Coarsing::write_numpy_locbuffer ( bool  squeeze)
inline

◆ write_numpy_npy()

int Coarsing::write_numpy_npy ( string  path,
bool  squeeze 
)

◆ write_vtk()

int Coarsing::write_vtk ( string  sout)

Write CG data as VTK.

◆ ~Coarsing()

Coarsing::~Coarsing ( )
inline

Variable Documentation

◆ box

v2d Coarsing::box

CG point location.

◆ CGP

vector<CGPoint> Coarsing::CGP

List of Coarse Graining points.

◆ CGPtemp

vector<CGPoint>* Coarsing::CGPtemp = nullptr

Temporary cgpoint list that can store temporal averages if needed.

◆ cT

int Coarsing::cT

Current timestep.

◆ cutoff

double Coarsing::cutoff

CG width, and cutoff.

◆ d [1/2]

int CGPoint::d

Dimension.

◆ d [2/2]

int Coarsing::d

Number of dimensions.

◆ data

struct Data Coarsing::data

Data storage.

◆ datalocation

int Field::datalocation = -1

For extra fields, identify the location in the vector of extra data.

◆ dx

v1d Coarsing::dx

Distances between CG points.

◆ extra

vector<double*> Data::extra

◆ extrafields

vector<std::tuple<std::string, int, int> > Data::extrafields

◆ Fidx

vector<int> Coarsing::Fidx

Where the fields is referenced in the fields vector in the CGPoint. -1 if not flagged.

◆ fields

v2d CGPoint::fields

1st dimension is time, second are fields

◆ Fields

vector<string> Coarsing::Fields

◆ FIELDS

vector<struct Field > Coarsing::FIELDS

All allowed fields (initialized in grid_getfields)

◆ flag

uint64_t Field::flag

Flag for the given field.

◆ flags

unsigned int Coarsing::flags

Pointer to the averaging window

Flags deciding which fields to coarse-grain

◆ Fname

vector<string> Coarsing::Fname

Flagged field names.

◆ fpq

vector<double *> Data::fpq

Force at contact.

◆ ftype

FieldType Field::ftype

Mainly used to identified the type of user defined fields.

◆ Ftype

vector<TensorOrder> Coarsing::Ftype

Flagged field types.

◆ hasrotfluct

bool Coarsing::hasrotfluct =false

◆ hasvelfluct

bool Coarsing::hasvelfluct =false

◆ id1

double* Data::id1

Index of first particle in contact.

◆ id2

double* Data::id2

Index of the second particle in contact.

◆ Imom

double* Data::Imom

Particle moment of inertia.

◆ location

v1d CGPoint::location

Location of the coarse graining point.

◆ lpq

vector<double *> Data::lpq

Branch vector of the contact, use compute_lpq() to populate this.

◆ mass

double* Data::mass

Particle masses.

◆ mpq

vector<double *> Data::mpq

Moment of particle 1 on 2.

◆ mqp

vector<double *> Data::mqp

Moment of particle 2 on 1.

◆ N

int Data::N = 0

Number of particles.

◆ name

string Field::name

Name for the given field.

◆ Ncf

int Data::Ncf

Number of contacts.

◆ neighbors

vector<int> CGPoint::neighbors

All the neighbors of the point given the window. 1st index is the point itself.

◆ Nnonper

int Data::Nnonper =-1

Used if additional particles are added as images through the periodic boundary conditions.

◆ Npt

int Coarsing::Npt

Number of coarse graining points.

◆ npt

vector<int> Coarsing::npt

Number of points per dimension.

◆ nptcum

vector<int> Coarsing::nptcum

Cumulated number of points per dimensions (usefull for quick finding of the closest CG for a grain)

◆ omega

vector<double *> Data::omega

Particle angular velocity.

◆ passlevel

Pass Field::passlevel

Identify at which moment the field gets calculated.

◆ pos

vector<double *> Data::pos

Particle positions.

◆ pospq

vector<double *> Data::pospq

Location of contact point.

◆ radius

double* Data::radius

Particle radius.

◆ rot_fluc

v2d Data::rot_fluc

Fluctuating angular velocity. Should not be externally provided but calculated, using the function Coarsing::compute_fluc_vel()

◆ Time

int Coarsing::Time

Total timesteps.

◆ type

TensorOrder Field::type

Tensorial order of the field: SCALAR, VECTOR or TENSOR.

◆ vel

vector<double *> Data::vel

Particle velocity.

◆ vel_fluc

v2d Data::vel_fluc

Fluctuating velocity. Should not be externally provided but calculated, using the function Coarsing::compute_fluc_vel()

◆ Window

LibBase* Coarsing::Window = nullptr