Loading...
Searching...
No Matches
GridDataOutput.hpp
Go to the documentation of this file.
/*
Copyright 2023 Inria, Bretagne–Atlantique Research Center
This file is part of the Open Porous Media project (OPM).
OPM 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.
OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_GRID_DATA_OUTPUT_HPP
#define OPM_GRID_DATA_OUTPUT_HPP
#include <opm/common/ErrorMacros.hpp>
#include <dune/grid/common/partitionset.hh>
#include <iosfwd>
#include <string>
namespace Opm::GridDataOutput
{
enum ConnectivityVertexOrder { DUNE = 0, VTK = 1 };
template <class GridView, unsigned int partitions>
class SimMeshDataAccessor
{
public:
explicit SimMeshDataAccessor(const GridView& gridView,
Dune::PartitionSet<partitions> dunePartition);
bool polyhedralCellPresent() const;
void countEntities();
template <typename T>
long writeGridPoints(T* x_inout, T* y_inout, T* z_inout, long max_size = 0) const;
template <typename VectType>
long writeGridPoints(VectType& x_inout, VectType& y_inout, VectType& z_inout) const;
template <typename T>
long writeGridPoints_AOS(T* xyz_inout, long max_size = 0) const;
template <typename VectType>
long writeGridPoints_AOS(VectType& xyz_inout) const;
template <typename T>
long writeGridPoints_SOA(T* xyz_inout, long max_size = 0) const;
template <typename VectType>
long writeGridPoints_SOA(VectType& xyz_inout) const;
template <typename Integer>
long writeConnectivity(Integer* connectivity_inout,
ConnectivityVertexOrder whichOrder, long max_size = 0) const;
template <typename VectType>
long writeConnectivity(VectType& connectivity_inout,
ConnectivityVertexOrder whichOrder) const;
template <typename Integer>
long writeOffsetsCells(Integer* offsets_inout, long max_size = 0) const;
template <typename VectType>
long writeOffsetsCells(VectType& offsets_inout) const;
template <typename Integer>
long writeCellTypes(Integer* types_inout, long max_size = 0) const;
template <typename VectType>
long writeCellTypes(VectType& types_inout) const;
std::string getPartitionTypeString() const;
Dune::PartitionSet<partitions> getPartition(void)
{
return this->dunePartition_;
}
void printGridDetails(std::ostream& outstr) const;
int getNCells() const
{
return ncells_;
}
int getNVertices() const
{
return nvertices_;
}
int getNCorners() const
{
return ncorners_;
}
std::string getError() const
{
return error_;
}
void clearError()
{
error_.clear();
}
bool hasError() const
{
return !error_.empty();
}
protected:
GridView gridView_; // the grid
Dune::PartitionSet<partitions> dunePartition_;
unsigned int partition_value_;
int ncells_;
int nvertices_;
int ncorners_;
int dimw_; // dimensions of the input grid
private:
std::string error_;
};
} // namespace Opm::GridDataOutput
#endif
Opm::GridDataOutput::ConnectivityVertexOrder
ConnectivityVertexOrder
Allows selection of order of vertices in writeConnectivity().
Definition GridDataOutput.hpp:93
Opm::GridDataOutput::SimMeshDataAccessor::ncorners_
int ncorners_
Current partition grid information.
Definition GridDataOutput.hpp:372
Opm::GridDataOutput::SimMeshDataAccessor::writeGridPoints_AOS
long writeGridPoints_AOS(T *xyz_inout, long max_size=0) const
Write the positions of vertices - directly to the pointers given in parameters as Array of Structures...
Definition GridDataOutput_impl.hpp:157
Opm::GridDataOutput::SimMeshDataAccessor::nvertices_
int nvertices_
Current partition grid information.
Definition GridDataOutput.hpp:368
Opm::GridDataOutput::SimMeshDataAccessor::SimMeshDataAccessor
SimMeshDataAccessor(const GridView &gridView, Dune::PartitionSet< partitions > dunePartition)
Construct a SimMeshDataAccessor working on a specific GridView and specialize to a Dune::PartitionSet...
Definition GridDataOutput_impl.hpp:36
Opm::GridDataOutput::SimMeshDataAccessor::countEntities
void countEntities()
Count the vertices, cells and corners.
Definition GridDataOutput_impl.hpp:55
Opm::GridDataOutput::SimMeshDataAccessor::writeGridPoints
long writeGridPoints(T *x_inout, T *y_inout, T *z_inout, long max_size=0) const
Write the positions of vertices - directly to the pointers given in parameters.
Definition GridDataOutput_impl.hpp:74
Opm::GridDataOutput::SimMeshDataAccessor::writeOffsetsCells
long writeOffsetsCells(Integer *offsets_inout, long max_size=0) const
Write the offsets values - directly to the pointer given in parameter 1.
Definition GridDataOutput_impl.hpp:394
Opm::GridDataOutput::SimMeshDataAccessor::writeConnectivity
long writeConnectivity(Integer *connectivity_inout, ConnectivityVertexOrder whichOrder, long max_size=0) const
Write the connectivity array - directly to the pointer given in parameter 1 Reorders the indices as s...
Definition GridDataOutput_impl.hpp:309
Opm::GridDataOutput::SimMeshDataAccessor::ncells_
int ncells_
Current partition grid information.
Definition GridDataOutput.hpp:364
Opm::GridDataOutput::SimMeshDataAccessor::polyhedralCellPresent
bool polyhedralCellPresent() const
Checks for cells that have polyhedral type within the current partition of cells.
Definition GridDataOutput_impl.hpp:46
Opm::GridDataOutput::SimMeshDataAccessor::writeCellTypes
long writeCellTypes(Integer *types_inout, long max_size=0) const
Write the cell types values - directly to the pointer given in parameter 1.
Definition GridDataOutput_impl.hpp:443
Opm::GridDataOutput::SimMeshDataAccessor::writeGridPoints_SOA
long writeGridPoints_SOA(T *xyz_inout, long max_size=0) const
Write the positions of vertices - directly to the pointers given in parameters as Structure of Arrays...
Definition GridDataOutput_impl.hpp:227