3#ifndef DUNE_GRID_IO_FILE_AMIRAMESH_PSURFACE_BOUNDARY_HH
4#define DUNE_GRID_IO_FILE_AMIRAMESH_PSURFACE_BOUNDARY_HH
14#include <psurface/PSurface.h>
15#include "psurface/AmiraMeshIO.h"
17#include <psurface/Hdf5IO.h>
21#include <amiramesh/AmiraMesh.h>
38 class PSurfaceBoundary
40 static_assert((dim==1 or dim==2),
"PSurfaceBoundaries can only have dimensions 1 or 2!");
54 PSurfaceBoundarySegment(
const std::shared_ptr<PSurfaceBoundary<dim> >& psurfaceBoundary,
int segment)
55 : psurfaceBoundary_(psurfaceBoundary),
65 psurface::StaticVector<float,dim> barCoords;
68 barCoords[0] = 1 - local[0] - local[1];
69 barCoords[1] = local[0];
71 barCoords[0] = 1 - local[0];
74 psurface::StaticVector<float,dim+1> r;
76 if (!psurfaceBoundary_->getPSurfaceObject()->positionMap(segment_, barCoords, r))
79 for (
int i=0; i<dim+1; i++)
85 std::shared_ptr<PSurfaceBoundary<dim> > psurfaceBoundary_;
92 PSurfaceBoundary(psurface::PSurface<dim,float>* psurface)
103 psurface::PSurface<dim,float>* getPSurfaceObject()
105 return psurface_.get();
115 static std::shared_ptr<PSurfaceBoundary<dim> > read(
const std::string& filename)
117 psurface::PSurface<dim,float>* newDomain;
121 if (filename.find(
".h5")==filename.length()-3) {
122 newDomain = psurface::Hdf5IO<float,dim>::read(filename);
124 return std::make_shared<PSurfaceBoundary<dim> >(newDomain);
129 std::unique_ptr<AmiraMesh> am(AmiraMesh::read(filename.c_str()));
132 DUNE_THROW(IOError,
"An error has occurred while reading " << filename);
135 = (psurface::PSurface<dim,float>*) psurface::AmiraMeshIO<float>::readAmiraMesh(am.get(), filename.c_str());
138 DUNE_THROW(IOError,
"An error has occurred while reading " << filename);
140 return std::make_shared<PSurfaceBoundary<dim> >(newDomain);
142 DUNE_THROW(IOError,
"The given file is not in a supported format!");
148 std::unique_ptr<psurface::PSurface<dim,float> > psurface_;
vector space out of a tensor product of fields.
Definition: fvector.hh:93
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:18
Provide a generic factory class for unstructured grids.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignment.hh:11
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:30