https://mooseframework.inl.gov
Loading...
Searching...
No Matches
functional_expansion_tools
include
utils
Hashing.h
Go to the documentation of this file.
1
//* This file is part of the MOOSE framework
2
//* https://mooseframework.inl.gov
3
//*
4
//* All rights reserved, see COPYRIGHT for full restrictions
5
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6
//*
7
//* Licensed under LGPL 2.1, please see LICENSE for details
8
//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10
#pragma once
11
12
#include "
MooseTypes.h
"
13
14
#include "libmesh/point.h"
15
20
namespace
hashing
21
{
22
typedef
std::size_t
HashValue
;
23
27
inline
void
28
hashCombine
(
HashValue
&
/* seed */
)
29
{
30
}
31
36
template
<
class
T
,
class
... Rest>
37
inline
void
38
hashCombine
(
HashValue
& seed,
const
T
& value, Rest... rest)
39
{
40
std::hash<T> hasher;
41
42
seed ^= hasher(value) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
43
hashCombine
(seed, rest...);
44
}
45
50
template
<
class
Container>
51
HashValue
52
hashLargeContainer
(Container
const
& container)
53
{
54
std::size_t size = container.size();
55
std::size_t stride = 1 + size / 10;
56
HashValue
seed = size;
57
58
for
(std::size_t i = 0; i < size; i += stride)
59
{
60
hashCombine
(seed, container.data()[i]);
61
}
62
63
return
seed;
64
}
65
69
inline
HashValue
70
hashCombine
(
const
libMesh::Point
& point)
71
{
72
// 'Magic seed' seed that provides entropy against the other hashCombine() seed
73
HashValue
seed = 3;
74
75
hashCombine
(seed, point(0), point(1), point(2));
76
77
return
seed;
78
}
79
83
inline
HashValue
84
hashCombine
(Real time,
const
libMesh::Point
& point)
85
{
86
// 'Magic seed' seed that provides entropy against the other hashCombine() seed
87
HashValue
seed = 42;
88
89
hashCombine
(seed, time, point(0), point(1), point(2));
90
91
return
seed;
92
}
93
}
T
const double T
Definition
GasLiquidMassTransferTest.C:19
MooseTypes.h
libMesh::Point
hashing
This namespace provides efficient algorithms for quickly hashing different types for checking identit...
Definition
Hashing.h:21
hashing::HashValue
std::size_t HashValue
Definition
Hashing.h:22
hashing::hashCombine
void hashCombine(HashValue &)
Final iteration of the variadic template with no additional arguments.
Definition
Hashing.h:28
hashing::hashLargeContainer
HashValue hashLargeContainer(Container const &container)
Hash function for sampling 10 points from a large container and hashing see: https://stackoverflow....
Definition
Hashing.h:52
Generated on Fri Aug 21 2026 13:41:02 for https://mooseframework.inl.gov by
1.9.8