8#include <kernel/geometry/mesh_atlas.hpp> 
    9#include <kernel/geometry/conformal_mesh.hpp> 
   10#include <kernel/geometry/mesh_part.hpp> 
   11#include <kernel/geometry/mesh_node.hpp> 
   12#include <kernel/geometry/partition_set.hpp> 
   13#include <kernel/util/xml_scanner.hpp> 
   22      template<
typename Shape_, 
int dim_ = Shape_::dimension>
 
   26        static void write_topology(std::ostream& os, 
const IndexSetHolder<Shape_>& ish, 
const String& sindent, 
bool skip_empty)
 
   29          TopoWriteHelper<Shape_, dim_-1>::write_topology(os, ish, sindent, skip_empty);
 
   35          const auto& index_set = ish.template get_index_set<dim_, 0>();
 
   39          if(skip_empty && (index_set.get_num_entities() == 
Index(0)))
 
   42          os << sindent << 
"<Topology dim=\"" << dim_ << 
"\">\n";
 
   43          for(Index i(0); i < index_set.get_num_entities(); ++i)
 
   45            const auto& idx = index_set[i];
 
   47            for(
int j(1); j < index_set.num_indices; ++j)
 
   51          os << sindent << 
"</Topology>\n";
 
   55      template<
typename Shape_>
 
   56      class TopoWriteHelper<Shape_, 0>
 
   59        static void write_topology(std::ostream&, 
const IndexSetHolder<Shape_>&, 
const String&, 
bool)
 
   65      template<
typename Shape_, 
int dim_ = Shape_::dimension>
 
   69        static void write_mapping(std::ostream& os, 
const TargetSetHolder<Shape_>& tsh, 
const String& sindent, 
bool skip_empty)
 
   72          MappWriteHelper<Shape_, dim_-1>::write_mapping(os, tsh, sindent, skip_empty);
 
   78          const auto& target_set = tsh.template get_target_set<dim_>();
 
   81          if(skip_empty && (target_set.get_num_entities() == 
Index(0)))
 
   84          os << sindent << 
"<Mapping dim=\"" << dim_ << 
"\">\n";
 
   85          for(Index i(0); i < target_set.get_num_entities(); ++i)
 
   86            os << sind << target_set[i] << 
'\n';
 
   87          os << sindent << 
"</Mapping>\n";
 
   91      template<
typename Shape_>
 
   92      class MappWriteHelper<Shape_, 0>
 
   95        static void write_mapping(std::ostream& os, 
const TargetSetHolder<Shape_>& tsh, 
const String& sindent, 
bool skip_empty)
 
  101          const auto& target_set = tsh.template get_target_set<0>();
 
  104          if(skip_empty && (target_set.get_num_entities() == 
Index(0)))
 
  107          os << sindent << 
"<Mapping dim=\"0\">\n";
 
  108          for(Index i(0); i < target_set.get_num_entities(); ++i)
 
  109            os << sind << target_set[i] << 
'\n';
 
  110          os << sindent << 
"</Mapping>\n";
 
  136      template<
int shape_dim_>
 
  142      template<
int shape_dim_>
 
  148      template<
typename Shape_, 
int num_coords_, 
typename Coord_>
 
  149      static String aux_meshtype_string(
const ConformalMesh<Shape_, num_coords_, Coord_>&)
 
  151        return String(
"conformal:") + aux_shape_string(Shape_()) + 
":" + 
stringify(
int(Shape_::dimension)) + 
":" + 
stringify(num_coords_);
 
  202      template<
typename RootMesh_>
 
  209        _os << 
_sindent << 
"<Chart name=\"" << name << 
"\">\n";
 
  210        chart.write(
_os, sind);
 
  220      template<
typename RootMesh_>
 
  227        for(
auto it = names.begin(); it != names.end(); ++it)
 
  230          XASSERTM(chart != 
nullptr, 
String(
"Chart '") + (*it) + 
"' not found in atlas");
 
  242      template<
typename Shape_, 
int num_coords_, 
typename Coord_>
 
  246        _os << 
_sindent << 
"<Mesh type=\"" << aux_meshtype_string(mesh) << 
"\"";
 
  248        for(
int i(1); i <= MeshType::shape_dim; ++i)
 
  254        Intern::TopoWriteHelper<Shape_>::write_topology(
_os, mesh.get_index_set_holder(), 
_sindent, 
false);
 
  275      template<
typename Mesh_>
 
  278        typedef typename Mesh_::ShapeType ShapeType;
 
  281        _os << 
" name=\"" << part_name << 
"\"";
 
  282        _os << 
" parent=\"" << parent_name << 
"\"";
 
  283        if(!chart_name.empty())
 
  284          _os << 
" chart=\"" << chart_name << 
"\"";
 
  285        _os << 
" topology=\"" << (meshpart.
has_topology() ? 
"full" : 
"none") << 
"\"";
 
  287        for(
int i(1); i <= ShapeType::dimension; ++i)
 
  293        Intern::MappWriteHelper<ShapeType>::write_mapping(
_os, meshpart.get_target_set_holder(), 
_sindent, 
true);
 
  297          Intern::TopoWriteHelper<ShapeType>::write_topology(
_os, *meshpart.get_topology(), 
_sindent, 
true);
 
  301        for(
auto it = attrs.begin(); it != attrs.end(); ++it)
 
  327        for(
Index i(0); i < graph.get_num_nodes_domain(); ++i)
 
  329          _os << 
_sindent << 
"<Patch rank=\"" << i << 
"\" size=\"" << graph.
degree(i) << 
"\">\n";
 
  349        for(
const auto& p : part_set.get_partitions())
 
  372      template<
typename RootMesh_>
 
  377        bool skip_internal_meshparts = 
true)
 
  379        const RootMesh_* root_mesh(
nullptr);
 
  380        if(mesh_node != 
nullptr)
 
  384        _os << 
"<FeatMeshFile version=\"1\"";
 
  385        if(root_mesh != 
nullptr)
 
  386          _os << 
" mesh=\"" << aux_meshtype_string(*root_mesh) << 
"\"";
 
  393        if(mesh_atlas != 
nullptr)
 
  400        if(mesh_node != 
nullptr)
 
  403          if(root_mesh != 
nullptr)
 
  408          for(
auto it = part_names.begin(); it != part_names.end(); ++it)
 
  413            if(skip_internal_meshparts && it->starts_with(
'_'))
 
  423        if(part_set != 
nullptr)
 
  431        _os << 
"</FeatMeshFile>\n";
 
  436        _os << 
"<FeatMeshFile version=\"1\">\n";
 
  440        _os << 
"</FeatMeshFile>\n";
 
  449      template<
int num_coords_, 
typename Coord_>
 
  456          const auto& v = vertex_set[i];
 
  458          for(
int j(1); j < num_coords_; ++j)
 
  475      template<
typename Data_>
 
  479        _os << 
" name=\"" << name << 
"\"";
 
  486          for(
int j(1); j < attr.get_dimension(); ++j)
 
  487            _os << 
' ' << attr(i, j);
 
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Adjacency Graph implementation.
ImageIterator image_begin(Index domain_node) const
Returns an iterator for the first adjacent image node.
ImageIterator image_end(Index domain_node) const
Returns an iterator for the first position past the last adjacent image node.
Index degree(Index domain_node) const
Returns the degree of a domain node.
Container for saving data related to mesh entities.
Index get_num_values() const
Returns the number of attribute values.
int get_dimension() const
Returns the number attribute dimension.
Mesh Atlas class template.
MeshChartType * find_mesh_chart(const String &name)
Searches for a mesh chart.
std::deque< String > get_chart_names() const
Returns the names of all charts of this atlas.
void _write_vertex_set(const VertexSet< num_coords_, Coord_ > &vertex_set)
Writes a vertex-set of a mesh into the file.
void write_partition(const Partition &partition)
Writes a partition to the file.
void write_chart(const Atlas::ChartBase< RootMesh_ > &chart, const String &name)
Writes a chart into the file.
void _write_attribute(const AttributeSet< Data_ > &attr, const String &name)
Writes an attribute of a mesh part into the file.
virtual ~MeshFileWriter()
virtual destructor
String _sindent
the current indentation string
void _push_indent()
increases the current indent by two spaces
std::ostream & _os
the output stream to write to
void write_mesh(const ConformalMesh< Shape_, num_coords_, Coord_ > &mesh)
Writes a (root) mesh into the file.
bool _indent
specifies whether indentation is to be used
void write_meshpart(const MeshPart< Mesh_ > &meshpart, const String &parent_name, const String &part_name, const String &chart_name)
Writes a mesh-part into the file.
void write(const RootMeshNode< RootMesh_ > *mesh_node, const MeshAtlas< RootMesh_ > *mesh_atlas=nullptr, const PartitionSet *part_set=nullptr, bool skip_internal_meshparts=true)
Writes a full domain to the file.
void _pop_indent()
decreases the current indent by two spaces
MeshFileWriter(std::ostream &os, bool indent=true)
Creates a writer for a given output stream.
void write_partition_set(const PartitionSet &part_set)
Writes all partitions of a partition set to the file.
void write_atlas(const MeshAtlas< RootMesh_ > &mesh_atlas)
Writes all charts of an atlas into the file.
MeshPartType * find_mesh_part(const String &part_name)
Searches this container for a MeshPart.
String find_mesh_part_chart_name(const String &part_name) const
Searches for a chart name belonging to a MeshPart by name.
std::deque< String > get_mesh_part_names(bool no_internals=false) const
Returns the names of all mesh parts of this node.
MeshType * get_mesh()
Returns the mesh of this node.
Class template for partial meshes.
const AttributeSetContainer & get_mesh_attributes() const
Returns a const reference to the mesh attributes container.
bool has_topology() const
Checks if this MeshPart has a mesh topology.
Index get_num_entities(int dim) const
Returns the number of entities.
Index get_num_patches() const
Index get_num_elements() const
const Adjacency::Graph & get_patches() const
Root mesh node class template.
String class implementation.
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.
Fixed-Sized Vertex Set class template.
Index get_num_vertices() const
Returns the number of vertices in the vertex set.
Hypercube shape tag struct template.
Simplex shape tag struct template.