CoDiPack  3.1.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
writeConnectivityData.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2026 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 <fstream>
38#include <iostream>
39#include <vector>
40
41#include "../../config.h"
42#include "../../misc/macros.hpp"
43#include "../../tapes/interfaces/fullTapeInterface.hpp"
44#include "../../tapes/statementEvaluators/statementEvaluatorInterface.hpp"
45#include "../identifierCacheOptimizer.hpp"
46
48namespace codi {
49
61 template<typename T_Tape>
62 struct WriteConnectivityData : public ApplyIdentifierModification<T_Tape, WriteConnectivityData<T_Tape>> {
63 using Tape = CODI_DD(T_Tape, CODI_DEFAULT_TAPE);
64
66
67 using Real = typename Tape::Real;
68 using Identifier = typename Tape::Identifier;
69 using EvalHandle = typename Tape::EvalHandle;
70
71 std::ofstream rhsConnectivity = {};
72 std::ofstream lhsConnectivity = {};
73
75
77
80
83 rhsConnectivity << stmtId << " " << id << "\n";
84 }
85
88 lhsConnectivity << stmtId << " " << id << "\n";
89 }
90
93 stmtId += 1;
94 }
95
97 void eval(std::string const& name) {
98 rhsConnectivity.open(name + "_rhs.dat");
99 lhsConnectivity.open(name + "_lhs.dat");
100
101 tape.iterateForward(*this);
102
103 rhsConnectivity.close();
104 lhsConnectivity.close();
105 }
106 };
107}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:97
CoDiPack - Code Differentiation Package.
Definition codi.hpp:97
ApplyIdentifierModification(Tape &tape)
Definition identifierCacheOptimizer.hpp:82
inlinevoid applyToInput(Identifier &id)
Write to rhs connectivity.
Definition writeConnectivityData.hpp:82
WriteConnectivityData(Tape &t)
Constructor.
Definition writeConnectivityData.hpp:79
typename Tape::EvalHandle EvalHandle
See FullTapeInterface.
Definition writeConnectivityData.hpp:69
Identifier stmtId
counter for statement data.
Definition writeConnectivityData.hpp:74
typename Tape::Real Real
See FullTapeInterface.
Definition writeConnectivityData.hpp:67
std::ofstream rhsConnectivity
Output stream for rhs connectivity.
Definition writeConnectivityData.hpp:71
inlinevoid applyPostOutputLogic()
Prepare for next statement.
Definition writeConnectivityData.hpp:92
Tape & tape
Tape that is modified.
Definition writeConnectivityData.hpp:76
void eval(std::string const &name)
Create the two files. See the class description for details.
Definition writeConnectivityData.hpp:97
T_Tape Tape
See WriteConnectivityData.
Definition writeConnectivityData.hpp:63
typename Tape::Identifier Identifier
See FullTapeInterface.
Definition writeConnectivityData.hpp:68
inlinevoid applyToOutput(Identifier &id)
Write to lhs connectivity.
Definition writeConnectivityData.hpp:87
std::ofstream lhsConnectivity
Output stream for lhs connectivity.
Definition writeConnectivityData.hpp:72
ApplyIdentifierModification< T_Tape, WriteConnectivityData< T_Tape > > Base
Base class abbreviation.
Definition writeConnectivityData.hpp:65