Commit f03f5df5 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[vtkoutputmod] pull out field type

parent a997fc21
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \ingroup InputOutput
* \brief Vtk field types available in Dumux
*/
#ifndef DUMUX_IO_VTK_FIELD_TYPE_HH
#define DUMUX_IO_VTK_FIELD_TYPE_HH
namespace Dumux::Vtk {
/*!
* \ingroup InputOutput
* \brief Identifier for vtk field types.
*/
enum class FieldType : unsigned int
{
element, vertex, automatic
};
} // end namespace Dumux::Vtk
#endif
......@@ -46,6 +46,7 @@
#include <dumux/discretization/method.hh>
#include "vtkfunction.hh"
#include "vtkfieldtype.hh"
#include "velocityoutput.hh"
namespace Dumux {
......@@ -64,9 +65,11 @@ class VtkOutputModuleBase
public:
//! export field type
enum class FieldType : unsigned int
struct [[deprecated("use Vtk::FieldType instead")]] FieldType
{
element, vertex, automatic
static constexpr auto element = Vtk::FieldType::element;
static constexpr auto vertex = Vtk::FieldType::vertex;
static constexpr auto automatic = Vtk::FieldType::automatic;
};
VtkOutputModuleBase(const GridGeometry& gridGeometry,
......@@ -105,7 +108,7 @@ public:
template<typename Vector>
void addField(const Vector& v,
const std::string& name,
FieldType fieldType = FieldType::automatic)
Vtk::FieldType fieldType = Vtk::FieldType::automatic)
{ addField(v, name, this->precision(), fieldType); }
/*!
......@@ -122,7 +125,7 @@ public:
void addField(const Vector& v,
const std::string& name,
Dumux::Vtk::Precision precision,
FieldType fieldType = FieldType::automatic)
Vtk::FieldType fieldType = Vtk::FieldType::automatic)
{
// Deduce the number of components from the given vector type
const auto nComp = getNumberOfComponents_(v);
......@@ -131,32 +134,32 @@ public:
const auto numVertexDofs = gridGeometry().vertexMapper().size();
// Automatically deduce the field type ...
if(fieldType == FieldType::automatic)
if(fieldType == Vtk::FieldType::automatic)
{
if(numElemDofs == numVertexDofs)
DUNE_THROW(Dune::InvalidStateException, "Automatic deduction of FieldType failed. Please explicitly specify FieldType::element or FieldType::vertex.");
if(v.size() == numElemDofs)
fieldType = FieldType::element;
fieldType = Vtk::FieldType::element;
else if(v.size() == numVertexDofs)
fieldType = FieldType::vertex;
fieldType = Vtk::FieldType::vertex;
else
DUNE_THROW(Dune::RangeError, "Size mismatch of added field!");
}
// ... or check if the user-specified type matches the size of v
else
{
if(fieldType == FieldType::element)
if(fieldType == Vtk::FieldType::element)
if(v.size() != numElemDofs)
DUNE_THROW(Dune::RangeError, "Size mismatch of added field!");
if(fieldType == FieldType::vertex)
if(fieldType == Vtk::FieldType::vertex)
if(v.size() != numVertexDofs)
DUNE_THROW(Dune::RangeError, "Size mismatch of added field!");
}
// add the appropriate field
if (fieldType == FieldType::element)
if (fieldType == Vtk::FieldType::element)
fields_.emplace_back(gridGeometry_.gridView(), gridGeometry_.elementMapper(), v, name, nComp, 0, dm_, precision);
else
fields_.emplace_back(gridGeometry_.gridView(), gridGeometry_.vertexMapper(), v, name, nComp, dim, dm_, precision);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment