17 #include "axom/core.hpp"
25 #include "serac/numerics/functional/element_restriction.hpp"
39 const char* name =
typeid(var).name();
42 char* demangled = abi::__cxa_demangle(name,
nullptr,
nullptr, &status);
43 std::string result((status == 0) ? demangled : name);
45 if constexpr (std::is_const_v<T>) {
46 result =
"const " + result;
64 std::ofstream outfile(filename);
65 for (
int i = 0; i < v.size(); i++) {
66 outfile << v[i] << std::endl;
78 std::ofstream outfile(filename);
79 for (
int i = 0; i < v.Size(); i++) {
80 outfile << v[i] << std::endl;
92 std::ofstream outfile(filename);
112 template <
typename T>
113 void writeToFile(axom::Array<T, 2, serac::detail::host_memory_space> arr, std::string filename)
115 std::ofstream outfile(filename);
117 for (axom::IndexType i = 0; i < arr.shape()[0]; i++) {
119 for (axom::IndexType j = 0; j < arr.shape()[1]; j++) {
120 outfile << arr(i, j);
121 if (j < arr.shape()[1] - 1) outfile <<
", ";
135 template <
typename T>
136 void writeToFile(axom::Array<T, 3, serac::detail::host_memory_space> arr, std::string filename)
138 std::ofstream outfile(filename);
140 outfile << std::setprecision(16);
142 for (axom::IndexType i = 0; i < arr.shape()[0]; i++) {
144 for (axom::IndexType j = 0; j < arr.shape()[1]; j++) {
146 for (axom::IndexType k = 0; k < arr.shape()[2]; k++) {
147 outfile << arr(i, j, k);
148 if (k < arr.shape()[2] - 1) outfile <<
", ";
151 if (j < arr.shape()[1] - 1) outfile <<
", ";
160 #include <cuda_runtime.h>
166 void printCUDAMemUsage()
169 cudaGetDeviceCount(&deviceCount);
173 size_t freeBytes, totalBytes;
174 cudaMemGetInfo(&freeBytes, &totalBytes);
175 size_t usedBytes = totalBytes - freeBytes;
177 std::cout <<
"Device Number: " << i << std::endl;
178 std::cout <<
" Total Memory (MB): " << (totalBytes / 1024.0 / 1024.0) << std::endl;
179 std::cout <<
" Free Memory (MB): " << (freeBytes / 1024.0 / 1024.0) << std::endl;
180 std::cout <<
" Used Memory (MB): " << (usedBytes / 1024.0 / 1024.0) << std::endl;
This file defines the host memory space.
Accelerator functionality.
std::string typeString(T &var)
Return string of given parameter's type.
std::ostream & operator<<(std::ostream &out, DoF dof)
stream output for DoF
void writeToFile(std::vector< T > v, std::string filename)
write an array of values out to file, in a space-separated format
a struct of metadata (index, sign, orientation) associated with a degree of freedom
int sign() const
get the sign field of this DoF
uint64_t index() const
get the index field of this DoF
uint64_t orientation() const
get the orientation field of this DoF