Shamrock
2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shammodels
sph
include
shammodels
sph
solvergraph
NeighCache.hpp
Go to the documentation of this file.
1
// -------------------------------------------------------//
2
//
3
// SHAMROCK code for hydrodynamics
4
// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5
// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6
// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7
//
8
// -------------------------------------------------------//
9
10
#pragma once
11
19
#include "
shambase/DistributedData.hpp
"
20
#include "
shamrock/solvergraph/IEdgeNamed.hpp
"
21
#include "
shamtree/TreeTraversal.hpp
"
22
23
namespace
shammodels::sph::solvergraph {
24
25
class
NeighCache
:
public
shamrock::solvergraph::IEdgeNamed
{
26
public
:
27
using
IEdgeNamed::IEdgeNamed;
28
29
shambase::DistributedData<shamrock::tree::ObjectCache>
neigh_cache;
30
31
shamrock::tree::ObjectCache
&get_cache(
u64
id
) {
return
neigh_cache.get(
id
); }
32
const
shamrock::tree::ObjectCache
&get_cache(
u64
id
)
const
{
return
neigh_cache.get(
id
); }
33
34
shamrock::tree::ObjectCache
&get(
u64
id
) {
return
neigh_cache.get(
id
); }
35
const
shamrock::tree::ObjectCache
&get(
u64
id
)
const
{
return
neigh_cache.get(
id
); }
36
37
inline
void
check_sizes(
const
shambase::DistributedData<u32>
&sizes)
const
{
38
on_distributeddata_diff(
39
neigh_cache,
40
sizes,
41
[](
u64
id
) {
42
shambase::throw_with_loc<std::runtime_error>
(
43
"Missing neigh cache in distributed data at id "
+ std::to_string(
id
));
44
},
45
[](
u64
id) {
46
// TODO
47
},
48
[](
u64
id) {
49
shambase::throw_with_loc<std::runtime_error>
(
50
"Extra neigh cache in distributed data at id "
+ std::to_string(
id
));
51
});
52
}
53
54
inline
void
free_alloc
() { neigh_cache = {}; }
55
};
56
57
}
// namespace shammodels::sph::solvergraph
DistributedData.hpp
IEdgeNamed.hpp
TreeTraversal.hpp
u64
std::uint64_t u64
64 bit unsigned integer
Definition
aliases_int.hpp:26
shambase::DistributedData
Represents a collection of objects distributed across patches identified by a u64 id.
Definition
DistributedData.hpp:43
shammodels::sph::solvergraph::NeighCache
Definition
NeighCache.hpp:25
shammodels::sph::solvergraph::NeighCache::free_alloc
void free_alloc()
Free allocated memory.
Definition
NeighCache.hpp:54
shamrock::solvergraph::IEdgeNamed
Definition
IEdgeNamed.hpp:23
shambase::throw_with_loc
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
Definition
exception.hpp:132
shamrock.tree::ObjectCache
Definition
TreeTraversal.hpp:375
Generated on Wed May 13 2026 13:21:49 for Shamrock by
1.9.8