Multi Resolution Molecular Dynamics 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{
28void dumpView(const std::string& filename, const ScalarView& view)
29{
30 auto data = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), view);
31 std::ofstream fout(filename);
32 for (idx_t i = 0; i < idx_c(data.extent(0)); ++i)
33 {
34 fout << data(i) << std::endl;
35 }
36 fout.close();
37}
38
42void dumpView(const std::string& filename, const MultiView& view)
43{
44 auto data = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), view);
45 std::ofstream fout(filename);
46 for (idx_t i = 0; i < idx_c(data.extent(0)); ++i)
47 {
48 for (idx_t j = 0; j < idx_c(data.extent(1)); ++j)
49 {
50 fout << data(i, j) << " ";
51 }
52 fout << std::endl;
53 }
54 fout.close();
55}
56} // namespace util
57} // namespace mrmd
All fundamental data containers used in MRMD.
Utility functions used throughout the library.
void dumpView(const std::string &filename, const ScalarView &view)
Dump a scalar view to a text file.
Definition dumpView.hpp:28
Top-level namespace of MRMD.
KOKKOS_INLINE_FUNCTION constexpr idx_t idx_c(const T &val)
Definition datatypes.hpp:93
int64_t idx_t
Definition datatypes.hpp:91
Kokkos::View< real_t ** > MultiView
Definition datatypes.hpp:161
Kokkos::View< real_t * > ScalarView
Definition datatypes.hpp:159