ViennaLS
Loading...
Searching...
No Matches
lsReader.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <fstream>
4
5
#include <
lsDomain.hpp
>
6
#include <
lsPreCompileMacros.hpp
>
7
8
namespace
viennals
{
9
10
using namespace
viennacore;
11
12
template
<
class
T,
int
D>
class
Reader
{
13
SmartPointer<Domain<T, D>> levelSet =
nullptr
;
14
std::string fileName;
15
16
public
:
17
Reader
() {}
18
19
Reader
(SmartPointer<
Domain<T, D>
> passedLevelSet)
20
: levelSet(passedLevelSet) {}
21
22
Reader
(SmartPointer<
Domain<T, D>
> passedLevelSet, std::string passedFileName)
23
: levelSet(passedLevelSet), fileName(passedFileName) {}
24
25
void
setLevelSet
(SmartPointer<
Domain<T, D>
> passedLevelSet) {
26
levelSet = passedLevelSet;
27
}
28
30
void
setFileName
(std::string passedFileName) { fileName = passedFileName; }
31
32
void
apply
() {
33
// check mesh
34
if
(levelSet ==
nullptr
) {
35
Logger::getInstance()
36
.addWarning(
"No mesh was passed to Reader. Not writing."
)
37
.print();
38
return
;
39
}
40
// check filename
41
if
(fileName.empty()) {
42
Logger::getInstance()
43
.addWarning(
"No file name specified for Reader. Not writing."
)
44
.print();
45
return
;
46
}
47
if
(fileName.find(
".lvst"
) != fileName.length() - 5) {
48
Logger::getInstance()
49
.addWarning(
"File name does not end in '.lvst', appending it."
)
50
.print();
51
fileName.append(
".lvst"
);
52
}
53
54
// Open file for writing and save serialized level set in it
55
std::ifstream fin(fileName, std::ios::binary);
56
57
levelSet->deserialize(fin);
58
59
fin.close();
60
}
61
};
62
63
// add all template specialisations for this class
64
PRECOMPILE_PRECISION_DIMENSION
(Reader)
65
66
}
// namespace viennals
viennals::Domain
Class containing all information about the level set, including the dimensions of the domain,...
Definition
lsDomain.hpp:28
viennals::Reader
Definition
lsReader.hpp:12
viennals::Reader::Reader
Reader(SmartPointer< Domain< T, D > > passedLevelSet, std::string passedFileName)
Definition
lsReader.hpp:22
viennals::Reader::setLevelSet
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition
lsReader.hpp:25
viennals::Reader::Reader
Reader(SmartPointer< Domain< T, D > > passedLevelSet)
Definition
lsReader.hpp:19
viennals::Reader::Reader
Reader()
Definition
lsReader.hpp:17
viennals::Reader::apply
void apply()
Definition
lsReader.hpp:32
viennals::Reader::setFileName
void setFileName(std::string passedFileName)
set file name for file to write
Definition
lsReader.hpp:30
lsDomain.hpp
lsPreCompileMacros.hpp
PRECOMPILE_PRECISION_DIMENSION
#define PRECOMPILE_PRECISION_DIMENSION(className)
Definition
lsPreCompileMacros.hpp:24
viennals
Definition
lsAdvect.hpp:46
include
viennals
lsReader.hpp
Generated by
1.12.0