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),
60 virtual Dune::FieldVector<double, dim+1> operator()(
const Dune::FieldVector<double,dim>& local)
const {
62 Dune::FieldVector<double, dim+1> result;
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))
77 DUNE_THROW(
Dune::GridError,
"psurface::positionMap returned error code");
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;
119 #if HAVE_PSURFACE_2_0 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_;
154 #endif // #if HAVE_PSURFACE 155 #endif // #ifndef DUNE_GRID_IO_FILE_AMIRAMESH_PSURFACE_BOUNDARY_HH Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:16
Provide a generic factory class for unstructured grids.
Include standard header files.
Definition: agrid.hh:59
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:29