ViennaLS
Loading...
Searching...
No Matches
lsWriter.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
Writer
{
13
SmartPointer<Domain<T, D>> levelSet =
nullptr
;
14
std::string fileName;
15
16
public
:
17
Writer
() {}
18
19
Writer
(SmartPointer<
Domain<T, D>
> passedLevelSet)
20
: levelSet(passedLevelSet) {}
21
22
Writer
(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 Writer. Not writing."
)
37
.print();
38
return
;
39
}
40
// check filename
41
if
(fileName.empty()) {
42
Logger::getInstance()
43
.addWarning(
"No file name specified for Writer. Not writing."
)
44
.print();
45
return
;
46
}
47
48
if
(fileName.find(
".lvst"
) != fileName.length() - 5) {
49
Logger::getInstance()
50
.addWarning(
"File name does not end in '.lvst', appending it."
)
51
.print();
52
fileName.append(
".lvst"
);
53
}
54
55
// Open file for writing and save serialized level set in it
56
std::ofstream fout(fileName, std::ios::binary);
57
58
levelSet->serialize(fout);
59
60
fout.close();
61
}
62
};
63
64
// add all template specialisations for this class
65
PRECOMPILE_PRECISION_DIMENSION
(Writer)
66
67
}
// namespace viennals
viennals::Domain
Class containing all information about the level set, including the dimensions of the domain,...
Definition
lsDomain.hpp:28
viennals::Writer
Definition
lsWriter.hpp:12
viennals::Writer::Writer
Writer(SmartPointer< Domain< T, D > > passedLevelSet, std::string passedFileName)
Definition
lsWriter.hpp:22
viennals::Writer::Writer
Writer(SmartPointer< Domain< T, D > > passedLevelSet)
Definition
lsWriter.hpp:19
viennals::Writer::setFileName
void setFileName(std::string passedFileName)
set file name for file to write
Definition
lsWriter.hpp:30
viennals::Writer::setLevelSet
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition
lsWriter.hpp:25
viennals::Writer::apply
void apply()
Definition
lsWriter.hpp:32
viennals::Writer::Writer
Writer()
Definition
lsWriter.hpp:17
lsDomain.hpp
lsPreCompileMacros.hpp
PRECOMPILE_PRECISION_DIMENSION
#define PRECOMPILE_PRECISION_DIMENSION(className)
Definition
lsPreCompileMacros.hpp:24
viennals
Definition
lsAdvect.hpp:46
include
viennals
lsWriter.hpp
Generated by
1.12.0