Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mojtaba Abdolkhani
ogs
Commits
6fb5933d
Commit
6fb5933d
authored
3 years ago
by
Tobias Meisel
Browse files
Options
Downloads
Patches
Plain Diff
[MeL/IO] XDMF: Add XdmfWriter RAII class
parent
cf284892
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MeshLib/IO/XDMF/XdmfWriter.cpp
+34
-0
34 additions, 0 deletions
MeshLib/IO/XDMF/XdmfWriter.cpp
MeshLib/IO/XDMF/XdmfWriter.h
+48
-0
48 additions, 0 deletions
MeshLib/IO/XDMF/XdmfWriter.h
with
82 additions
and
0 deletions
MeshLib/IO/XDMF/XdmfWriter.cpp
0 → 100644
+
34
−
0
View file @
6fb5933d
#include
"XdmfWriter.h"
#include
<fstream>
#include
"writeXdmf.h"
#include
"BaseLib/RunTime.h"
#include
"BaseLib/Logging.h"
namespace
MeshLib
::
IO
{
XdmfWriter
::
XdmfWriter
(
std
::
string
const
&
xdmf_filename
,
std
::
function
<
std
::
string
(
std
::
vector
<
double
>
)
>
xdmf_writer_fn
)
:
filename
(
xdmf_filename
),
xdmf_writer
(
xdmf_writer_fn
)
{
}
XdmfWriter
::~
XdmfWriter
()
{
BaseLib
::
RunTime
time_output
;
time_output
.
start
();
std
::
ofstream
fout
;
fout
.
open
(
this
->
filename
);
fout
<<
xdmf_writer
(
times
);
INFO
(
"[time] Output of XDMF took {:g} s."
,
time_output
.
elapsed
());
}
void
XdmfWriter
::
addTimeStep
(
double
const
&
time_step
)
{
times
.
push_back
(
time_step
);
}
}
// namespace MeshLib::IO
\ No newline at end of file
This diff is collapsed.
Click to expand it.
MeshLib/IO/XDMF/XdmfWriter.h
0 → 100644
+
48
−
0
View file @
6fb5933d
/**
* \file
* \author Tobias Meisel
* \date 2021-06-30
* \brief Collects and holds all metadata for writing XDMF file
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*/
#pragma once
#include
<functional>
#include
<string>
namespace
MeshLib
::
IO
{
class
XdmfWriter
final
{
public:
/**
* \brief Writes xdmf string into file on class destruction
* @param xdmf_filename absolute or relative filepath to the xdmf file
* @param xdmf_writer_fn function that generates xdmf string
*/
XdmfWriter
(
std
::
string
const
&
xdmf_filename
,
std
::
function
<
std
::
string
(
std
::
vector
<
double
>
)
>
xdmf_writer_fn
);
XdmfWriter
(
XdmfWriter
&&
)
=
default
;
XdmfWriter
&
operator
=
(
XdmfWriter
&&
)
=
default
;
XdmfWriter
(
XdmfWriter
const
&
)
=
delete
;
XdmfWriter
&
operator
=
(
XdmfWriter
const
&
)
=
delete
;
~
XdmfWriter
();
/**
* \brief Adds data for lazy (xdmf) writing algorithm
* @param time_step time value of the current time_step
*/
void
addTimeStep
(
double
const
&
time_step
);
private:
std
::
string
filename
;
std
::
vector
<
double
>
times
;
std
::
function
<
std
::
string
(
std
::
vector
<
double
>
)
>
xdmf_writer
;
};
}
// namespace MeshLib::IO
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment