-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: Use inheritance for type-erasure of Magnetic Field Provide…
…rs (1/2) (#666) * mvp add any cache fix scalable b field remove explicit ctor / ass op doc comments BFieldBase -> BFieldProvider gcc9 fix switch to SBO cache use static instead of realloc for every instance fix remove clone method on handler format align array buffer * compile fix * fix segfault because of missing move construction * also add copy construct * make cache type handle non-copyable caches * adjust to bfield cache type not being copyable anymore in unit test * move SBO cache to separate file, remove AnyCache * rename BFieldProvider to MagneticFieldProvider * fix a few spots where the rename wasn't done yet Co-authored-by: Andreas Salzburger <Andreas.Salzburger@cern.ch>
- Loading branch information
1 parent
3b345dd
commit 46309cd
Showing
23 changed files
with
558 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2021 CERN for the benefit of the Acts project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#pragma once | ||
|
||
#include "Acts/Definitions/Algebra.hpp" | ||
#include "Acts/MagneticField/MagneticFieldContext.hpp" | ||
#include "Acts/MagneticField/detail/SmallObjectCache.hpp" | ||
|
||
#include <array> | ||
#include <memory> | ||
|
||
namespace Acts { | ||
|
||
/// Base class for all magnetic field providers | ||
class MagneticFieldProvider { | ||
public: | ||
using Cache = detail::SmallObjectCache; | ||
|
||
/// @brief Make an opaque cache for the magnetic field | ||
/// | ||
/// @param mctx The magnetic field context to generate cache for | ||
/// @return Cache The opaque cache object | ||
virtual Cache makeCache(const MagneticFieldContext& mctx) const = 0; | ||
|
||
/// @brief retrieve magnetic field value | ||
/// | ||
/// @param [in] position global 3D position | ||
/// | ||
/// @return magnetic field vector at given position | ||
virtual Vector3 getField(const Vector3& position, Cache& cache) const = 0; | ||
|
||
/// @brief retrieve magnetic field value | ||
/// | ||
/// @param [in] position global 3D position | ||
/// @param [in,out] cache Cache object. Contains field cell used for | ||
/// interpolation | ||
/// | ||
/// @return magnetic field vector at given position | ||
virtual Vector3 getField(const Vector3& position) const = 0; | ||
|
||
/// @brief retrieve magnetic field value & its gradient | ||
/// | ||
/// @param [in] position global 3D position | ||
/// @param [out] derivative gradient of magnetic field vector as (3x3) matrix | ||
/// @return magnetic field vector | ||
virtual Vector3 getFieldGradient(const Vector3& position, | ||
ActsMatrix<3, 3>& derivative) const = 0; | ||
|
||
/// @brief retrieve magnetic field value & its gradient | ||
/// | ||
/// @param [in] position global 3D position | ||
/// @param [out] derivative gradient of magnetic field vector as (3x3) matrix | ||
/// @param [in,out] cache Cache object. Contains field cell used for | ||
/// @return magnetic field vector | ||
virtual Vector3 getFieldGradient(const Vector3& position, | ||
ActsMatrix<3, 3>& derivative, | ||
Cache& cache) const = 0; | ||
}; | ||
|
||
} // namespace Acts |
Oops, something went wrong.