CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
jacobianComputationLogic.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2024 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://scicomp.rptu.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of CoDiPack (http://scicomp.rptu.de/software/codi).
11 *
12 * CoDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * CoDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU General Public License for more details.
22 * You should have received a copy of the GNU
23 * General Public License along with CoDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * For other licensing options please contact us.
27 *
28 * Authors:
29 * - SciComp, University of Kaiserslautern-Landau:
30 * - Max Sagebaum
31 * - Johannes Blühdorn
32 * - Former members:
33 * - Tim Albring
34 */
35#pragma once
36
37#include <type_traits>
38#include <utility>
39
40#include "../../../config.h"
42#include "../../../traits/expressionTraits.hpp"
43#include "../traversalLogic.hpp"
44
46namespace codi {
47
52 template<typename T_Impl>
53 struct JacobianComputationLogic : public TraversalLogic<T_Impl> {
54 public:
55
57
58 /*******************************************************************************/
61
63 template<typename Node, typename Jacobian, typename... Args>
64 void handleJacobianOnActive(Node const& node, Jacobian jacobian, Args&&... args);
65
67 /*******************************************************************************/
70
72 template<typename Node, typename Jacobian, typename... Args>
74 Args&&... args) {
75 cast().handleJacobianOnActive(node, jacobian, std::forward<Args>(args)...);
76 }
77
79
83 template<size_t ChildNumber, typename Child, typename Root, typename Jacobian, typename... Args>
84 CODI_INLINE void link(Child const& child, Root const& root, Jacobian const& jacobian, Args&&... args) {
86 auto curJacobian = linkJacobian * jacobian;
87
88 cast().toNode(child, curJacobian, std::forward<Args>(args)...);
89 }
90
92
93 private:
94
95 CODI_INLINE Impl& cast() {
96 return static_cast<Impl&>(*this);
97 }
98 };
99}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:111
typename std::enable_if< IsLhsExpression< Expr >::value, T >::type EnableIfLhsExpression
Enable if wrapper for IsLhsExpression.
Definition expressionTraits.hpp:137
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
Definition jacobianComputationLogic.hpp:53
void link(Child const &child, Root const &root, Jacobian const &jacobian, Args &&... args)
Definition jacobianComputationLogic.hpp:84
void handleJacobianOnActive(Node const &node, Jacobian jacobian, Args &&... args)
Called for leaf nodes which implement LhsExpressionInterface.
T_Impl Impl
See JacobianComputationLogic.
Definition jacobianComputationLogic.hpp:56
ExpressionTraits::EnableIfLhsExpression< Node > leaf(Node const &node, Jacobian jacobian, Args &&... args)
Called for all leaf nodes in the expression.
Definition jacobianComputationLogic.hpp:73
Default implementation of the Jacobian interface.
Definition jacobian.hpp:60
Traversal of CoDiPack expressions.
Definition traversalLogic.hpp:56
void node(Node const &node, Args &&... args)
Called for each node in the expression.
Definition traversalLogic.hpp:86