MRMD 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
dumpView.hpp
Go to the documentation of this file.
1// Copyright 2024 Sebastian Eibl
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <fstream>
18
19#include "datatypes.hpp"
20
21namespace mrmd
22{
23namespace util
24{
25void dumpView(const std::string& filename, const ScalarView& view)
26{
27 auto data = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), view);
28 std::ofstream fout(filename);
29 for (idx_t i = 0; i < idx_c(data.extent(0)); ++i)
30 {
31 fout << data(i) << std::endl;
32 }
33 fout.close();
34}
35
36void dumpView(const std::string& filename, const MultiView& view)
37{
38 auto data = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), view);
39 std::ofstream fout(filename);
40 for (idx_t i = 0; i < idx_c(data.extent(0)); ++i)
41 {
42 for (idx_t j = 0; j < idx_c(data.extent(1)); ++j)
43 {
44 fout << data(i, j) << " ";
45 }
46 fout << std::endl;
47 }
48 fout.close();
49}
50} // namespace util
51} // namespace mrmd
void dumpView(const std::string &filename, const ScalarView &view)
Definition dumpView.hpp:25
Definition BerendsenBarostat.cpp:18
Kokkos::View< real_t * > ScalarView
Definition datatypes.hpp:159
KOKKOS_INLINE_FUNCTION constexpr idx_t idx_c(const T &val)
Definition datatypes.hpp:93
Kokkos::View< real_t ** > MultiView
Definition datatypes.hpp:161
int64_t idx_t
Definition datatypes.hpp:91