diff --git a/dumux/io/pointcloudvtkwriter.hh b/dumux/io/pointcloudvtkwriter.hh index 8b9e546f512268460ecd83936061e97f311306ed..946254fd1b0e1e3594bf357ca996774ca10031f1 100644 --- a/dumux/io/pointcloudvtkwriter.hh +++ b/dumux/io/pointcloudvtkwriter.hh @@ -178,10 +178,10 @@ public: * \param name The name 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()); - scalarPointData_.push_back(ScalarFunction(v, name, ncomps)); + assert(v.size() == coordinates_.size()); + scalarPointData_.push_back(ScalarFunction(v, name, 1)); } /*! @@ -191,10 +191,10 @@ public: * \param name The name 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()); - vectorPointData_.push_back(VectorFunction(v, name, ncomps)); + vectorPointData_.push_back(VectorFunction(v, name, 3)); } /*! diff --git a/dumux/io/staggeredvtkoutputmodule.hh b/dumux/io/staggeredvtkoutputmodule.hh index a531c138196dcaa90f640b279dfa6799b5315372..bd1fcdaea40eefa0c27eef9085ea3b4efbeee8da 100644 --- a/dumux/io/staggeredvtkoutputmodule.hh +++ b/dumux/io/staggeredvtkoutputmodule.hh @@ -33,6 +33,7 @@ namespace Dumux { + /*! * \ingroup InputOutput * \brief A VTK output module to simplify writing dumux simulation data to VTK format @@ -62,9 +63,6 @@ class StaggeredVtkOutputModule : public VtkOutputModule<TypeTag> typename DofTypeIndices::CellCenterIdx cellCenterIdx; 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 FaceVarVectorDataInfo { std::function<GlobalPosition(const SubControlVolumeFace& scvf, const FaceVariables&)> get; std::string name; }; @@ -101,11 +99,19 @@ public: ////////////////////////////////////////////////////////////////////////////////////////////// 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)) - int x; - // fields_.emplace_back(gridGeom_.gridView(), gridGeom_.elementMapper(), v, name, nComp, 0); + { + if(!coordinatesInitialized_) + updateCoordinates_(); + + faceWriter_->addPointData(v, name); + } else DUNE_THROW(Dune::RangeError, "Size mismatch of added field!"); } @@ -200,11 +206,12 @@ private: if(!faceVarVectorDataInfo_.empty()) 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); - // faceScalarFields_.clear(); - // faceVectorFields_.clear(); + coordinates_.clear(); + coordinates_.shrink_to_fit(); + coordinatesInitialized_ = false; }