Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
GhostHandlerEdge.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/memory.hpp"
22#include <optional>
23
24namespace shammodels::gsph::solvergraph {
25
27 template<class Tvec>
29 public:
30 using IEdgeNamed::IEdgeNamed;
32
33 std::optional<GhostHandle> handler;
34
35 GhostHandle &get() {
36 if (!handler.has_value()) {
38 }
39 return handler.value();
40 }
41
42 const GhostHandle &get() const {
43 if (!handler.has_value()) {
45 }
46 return handler.value();
47 }
48
49 bool has_value() const { return handler.has_value(); }
50
51 void set(GhostHandle &&h) {
52 handler.reset();
53 handler.emplace(std::move(h));
54 }
55
57 inline virtual void free_alloc() override { handler.reset(); }
58 };
59
60} // namespace shammodels::gsph::solvergraph
GSPH-specific ghost handler using Newtonian physics field names.
SolverGraph edge for GSPH ghost handler.
virtual void free_alloc() override
Free the allocated handler.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.