Skip to content
Snippets Groups Projects
Commit b4aa3f06 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[staggered][io] Complete faceWriter

* now allows writing out any Scalar valued or GlobalPos-type data on face
parent ab2b1f23
No related branches found
No related tags found
Loading
...@@ -178,10 +178,10 @@ public: ...@@ -178,10 +178,10 @@ public:
* \param name The name of the data set * \param name The name of the data set
* \param ncomps The number of components of the data set * \param ncomps The number of components of the data set
*/ */
void addPointData(const std::vector<Scalar>& v, const std::string &name, int ncomps = 1) void addPointData(const std::vector<Scalar>& v, const std::string &name)
{ {
assert(v.size() == ncomps * coordinates_.size()); assert(v.size() == coordinates_.size());
scalarPointData_.push_back(ScalarFunction(v, name, ncomps)); scalarPointData_.push_back(ScalarFunction(v, name, 1));
} }
/*! /*!
...@@ -191,10 +191,10 @@ public: ...@@ -191,10 +191,10 @@ public:
* \param name The name of the data set * \param name The name of the data set
* \param ncomps The number of components of the data set * \param ncomps The number of components of the data set
*/ */
void addPointData(const std::vector<GlobalPosition>& v, const std::string &name, int ncomps = 1) void addPointData(const std::vector<GlobalPosition>& v, const std::string &name)
{ {
assert(v.size() == coordinates_.size()); assert(v.size() == coordinates_.size());
vectorPointData_.push_back(VectorFunction(v, name, ncomps)); vectorPointData_.push_back(VectorFunction(v, name, 3));
} }
/*! /*!
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
namespace Dumux namespace Dumux
{ {
/*! /*!
* \ingroup InputOutput * \ingroup InputOutput
* \brief A VTK output module to simplify writing dumux simulation data to VTK format * \brief A VTK output module to simplify writing dumux simulation data to VTK format
...@@ -62,9 +63,6 @@ class StaggeredVtkOutputModule : public VtkOutputModule<TypeTag> ...@@ -62,9 +63,6 @@ class StaggeredVtkOutputModule : public VtkOutputModule<TypeTag>
typename DofTypeIndices::CellCenterIdx cellCenterIdx; typename DofTypeIndices::CellCenterIdx cellCenterIdx;
typename DofTypeIndices::FaceIdx faceIdx; typename DofTypeIndices::FaceIdx faceIdx;
struct PriVarScalarDataInfo { unsigned int pvIdx; std::string name; };
struct PriVarVectorDataInfo { std::vector<unsigned int> pvIdx; std::string name; };
struct FaceVarScalarDataInfo { std::function<Scalar(const FaceVariables&)> get; std::string name; }; struct FaceVarScalarDataInfo { std::function<Scalar(const FaceVariables&)> get; std::string name; };
struct FaceVarVectorDataInfo { std::function<GlobalPosition(const SubControlVolumeFace& scvf, const FaceVariables&)> get; std::string name; }; struct FaceVarVectorDataInfo { std::function<GlobalPosition(const SubControlVolumeFace& scvf, const FaceVariables&)> get; std::string name; };
...@@ -101,11 +99,19 @@ public: ...@@ -101,11 +99,19 @@ public:
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
template<typename Vector> template<typename Vector>
void addFaceField(const Vector& v, const std::string& name, int nComp = 1) void addFaceField(const Vector& v, const std::string& name)
{ {
static_assert(std::is_same<Vector, std::vector<Scalar>>::value ||
std::is_same<Vector, std::vector<GlobalPosition>>::value,
"Only vectors of Scalar or GlobalPosition are supported");
if (v.size() == this->gridGeom_.gridView().size(1)) if (v.size() == this->gridGeom_.gridView().size(1))
int x; {
// fields_.emplace_back(gridGeom_.gridView(), gridGeom_.elementMapper(), v, name, nComp, 0); if(!coordinatesInitialized_)
updateCoordinates_();
faceWriter_->addPointData(v, name);
}
else else
DUNE_THROW(Dune::RangeError, "Size mismatch of added field!"); DUNE_THROW(Dune::RangeError, "Size mismatch of added field!");
} }
...@@ -200,11 +206,12 @@ private: ...@@ -200,11 +206,12 @@ private:
if(!faceVarVectorDataInfo_.empty()) if(!faceVarVectorDataInfo_.empty())
for (std::size_t i = 0; i < faceVarVectorDataInfo_.size(); ++i) for (std::size_t i = 0; i < faceVarVectorDataInfo_.size(); ++i)
faceWriter_->addPointData(faceVarVectorData[i], faceVarVectorDataInfo_[i].name, 3); faceWriter_->addPointData(faceVarVectorData[i], faceVarVectorDataInfo_[i].name);
sequenceWriter_.write(time); sequenceWriter_.write(time);
// faceScalarFields_.clear(); coordinates_.clear();
// faceVectorFields_.clear(); coordinates_.shrink_to_fit();
coordinatesInitialized_ = false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment