Skip to content
Snippets Groups Projects
Commit 439dd572 authored by Norihiro Watanabe's avatar Norihiro Watanabe
Browse files

apply clang-format to FEFLOW IO

parent d3323efd
No related branches found
No related tags found
No related merge requests found
......@@ -24,18 +24,18 @@
#include "GeoLib/Point.h"
#include "GeoLib/Polygon.h"
namespace GeoLib
{
namespace IO
{
void FEFLOWGeoInterface::readFEFLOWFile(const std::string &filename, GeoLib::GEOObjects& geoObjects)
void FEFLOWGeoInterface::readFEFLOWFile(const std::string& filename,
GeoLib::GEOObjects& geoObjects)
{
std::ifstream in(filename.c_str());
if (!in)
{
ERR("FEFLOWGeoInterface::readFEFLOWFile(): Could not open file %s.", filename.c_str());
ERR("FEFLOWGeoInterface::readFEFLOWFile(): Could not open file %s.",
filename.c_str());
return;
}
......@@ -51,14 +51,14 @@ void FEFLOWGeoInterface::readFEFLOWFile(const std::string &filename, GeoLib::GEO
{
getline(in, line_string);
//....................................................................
// CLASS
if (line_string.find("CLASS") != std::string::npos) // the version number follows afterward, e.g. CLASS (v.5.313)
// CLASS: the version number follows afterward, e.g. CLASS (v.5.313)
if (line_string.find("CLASS") != std::string::npos)
{
getline(in, line_string);
line_stream.str(line_string);
// problem class, time mode, problem orientation, dimension, ...
unsigned dummy = 0;
for (int i=0; i<3; i++)
for (int i = 0; i < 3; i++)
line_stream >> dummy;
line_stream >> dimension;
line_stream.clear();
......@@ -69,7 +69,7 @@ void FEFLOWGeoInterface::readFEFLOWFile(const std::string &filename, GeoLib::GEO
{
getline(in, line_string);
line_stream.str(line_string);
double vec[3] = { };
double vec[3] = {};
line_stream >> vec[0] >> vec[1] >> vec[2];
if (vec[0] == 0.0 && vec[1] == -1.0 && vec[2] == 0.0)
// x-z plane
......@@ -104,13 +104,15 @@ void FEFLOWGeoInterface::readFEFLOWFile(const std::string &filename, GeoLib::GEO
(*pt)[1] = .0;
}
}
}
void FEFLOWGeoInterface::readPoints(QDomElement &nodesEle, const std::string &tag, int dim, std::vector<GeoLib::Point*> &points)
void FEFLOWGeoInterface::readPoints(QDomElement& nodesEle,
const std::string& tag,
int dim,
std::vector<GeoLib::Point*>& points)
{
QDomElement xmlEle = nodesEle.firstChildElement(QString::fromStdString(tag));
QDomElement xmlEle =
nodesEle.firstChildElement(QString::fromStdString(tag));
if (xmlEle.isNull())
return;
QString str_pt_list1 = xmlEle.text();
......@@ -120,10 +122,11 @@ void FEFLOWGeoInterface::readPoints(QDomElement &nodesEle, const std::string &ta
{
std::getline(ss, line_str);
BaseLib::trim(line_str, ' ');
if (line_str.empty()) continue;
if (line_str.empty())
continue;
std::istringstream line_ss(line_str);
std::size_t pt_id = 0;
std::array<double,3> pt_xyz;
std::array<double, 3> pt_xyz;
line_ss >> pt_id;
for (int i = 0; i < dim; i++)
line_ss >> pt_xyz[i];
......@@ -131,8 +134,10 @@ void FEFLOWGeoInterface::readPoints(QDomElement &nodesEle, const std::string &ta
}
}
void FEFLOWGeoInterface::readSuperMesh(std::ifstream &in, unsigned dimension, std::vector<GeoLib::Point*>* &points, std::vector<GeoLib::Polyline*>* &lines)
void FEFLOWGeoInterface::readSuperMesh(std::ifstream& in,
unsigned dimension,
std::vector<GeoLib::Point*>*& points,
std::vector<GeoLib::Polyline*>*& lines)
{
// get XML strings
std::ostringstream oss;
......@@ -156,7 +161,7 @@ void FEFLOWGeoInterface::readSuperMesh(std::ifstream &in, unsigned dimension, st
}
// get geometry data from XML
QDomElement docElem = doc.documentElement(); // #supermesh
QDomElement docElem = doc.documentElement(); // #supermesh
// #nodes
points = new std::vector<GeoLib::Point*>();
QDomElement nodesEle = docElem.firstChildElement("nodes");
......@@ -167,7 +172,7 @@ void FEFLOWGeoInterface::readSuperMesh(std::ifstream &in, unsigned dimension, st
const QString str = nodesEle.attribute("count");
const long n_points = str.toLong();
points->resize(n_points);
//fixed
// fixed
readPoints(nodesEle, "fixed", dimension, *points);
readPoints(nodesEle, "linear", dimension, *points);
readPoints(nodesEle, "parabolic", dimension, *points);
......@@ -211,5 +216,5 @@ void FEFLOWGeoInterface::readSuperMesh(std::ifstream &in, unsigned dimension, st
}
}
} // IO
} // GeoLib
} // IO
} // GeoLib
......@@ -17,16 +17,15 @@ class QDomElement;
namespace GeoLib
{
class GEOObjects;
class Point;
class Polyline;
class GEOObjects;
class Point;
class Polyline;
}
namespace GeoLib
{
namespace IO
{
/**
* Interface to geometric data in FEFLOW files
*/
......@@ -39,22 +38,27 @@ public:
* This function reads geometry data given in Supermesh.
*
* @param filename FEFLOW file name
* @param geo_objects Geometric objects where imported geometry data are added
* @param geo_objects Geometric objects where imported geometry data are
* added
*/
void readFEFLOWFile(const std::string &filename, GeoLib::GEOObjects& geo_objects);
void readFEFLOWFile(const std::string& filename,
GeoLib::GEOObjects& geo_objects);
/// read points and polylines in Supermesh section
///
/// A super mesh is a collection of polygons, lines and points in the 2D plane
/// and will be used for mesh generation and to define the modeling region
static void readSuperMesh(std::ifstream &feflow_file, unsigned dimension, std::vector<GeoLib::Point*>* &points, std::vector<GeoLib::Polyline*>* &lines);
/// A super mesh is a collection of polygons, lines and points in the 2D
/// plane and will be used for mesh generation and to define the modeling
/// region
static void readSuperMesh(std::ifstream& feflow_file, unsigned dimension,
std::vector<GeoLib::Point*>*& points,
std::vector<GeoLib::Polyline*>*& lines);
private:
//// read point data in Supermesh
static void readPoints(QDomElement &nodesEle, const std::string &tag, int dim, std::vector<GeoLib::Point*> &points);
static void readPoints(QDomElement& nodesEle, const std::string& tag,
int dim, std::vector<GeoLib::Point*>& points);
};
} // IO
} // GeoLib
} // IO
} // GeoLib
#endif /* FEFLOWGEOINTERFACE_H_ */
This diff is collapsed.
......@@ -15,26 +15,25 @@
namespace GeoLib
{
class Point;
class Polyline;
class Point;
class Polyline;
}
namespace MeshLib
{
class Mesh;
class Element;
class Node;
enum class MeshElemType;
class Mesh;
class Element;
class Node;
enum class MeshElemType;
}
namespace MeshLib
{
namespace IO
{
/**
* Read FEFLOW model files (*.fem) into OGS data structure. Currently this class supports
* only import of mesh data and some geometry given in Supermesh section.
* Read FEFLOW model files (*.fem) into OGS data structure. Currently this class
* supports only import of mesh data and some geometry given in Supermesh section.
*/
class FEFLOWMeshInterface
{
......@@ -42,12 +41,13 @@ public:
/**
* read a FEFLOW Model file (*.fem) in ASCII format (Version 5.4)
*
* This function reads mesh data in addition to geometry data given in Supermesh.
* This function reads mesh data in addition to geometry data given in
* Supermesh.
*
* @param filename FEFLOW file name
* @return a pointer to a created OGS mesh
*/
MeshLib::Mesh* readFEFLOWFile(const std::string &filename);
MeshLib::Mesh* readFEFLOWFile(const std::string& filename);
private:
// CLASS
......@@ -85,28 +85,40 @@ private:
};
/// read node indices and create a mesh element
MeshLib::Element* readElement(const FEM_DIM &fem_dim, const MeshLib::MeshElemType elem_type, const std::string& line, const std::vector<MeshLib::Node*> &nodes);
MeshLib::Element* readElement(const FEM_DIM& fem_dim,
const MeshLib::MeshElemType elem_type,
const std::string& line,
const std::vector<MeshLib::Node*>& nodes);
/// read node coordinates
void readNodeCoordinates(std::ifstream &in, const FEM_CLASS &fem_class, const FEM_DIM &fem_dim, std::vector<MeshLib::Node*> &nodes);
void readNodeCoordinates(std::ifstream& in,
const FEM_CLASS& fem_class,
const FEM_DIM& fem_dim,
std::vector<MeshLib::Node*>& nodes);
/// read elevation data
void readElevation(std::ifstream &in, const FEM_CLASS &fem_class, const FEM_DIM &fem_dim, std::vector<MeshLib::Node*> &vec_nodes);
void readElevation(std::ifstream& in,
const FEM_CLASS& fem_class,
const FEM_DIM& fem_dim,
std::vector<MeshLib::Node*>& vec_nodes);
//// parse node lists
std::vector<std::size_t> getIndexList(const std::string &str_ranges);
std::vector<std::size_t> getIndexList(const std::string& str_ranges);
/// parse ELEMENTALSETS
void readELEMENTALSETS(std::ifstream &in, std::vector<std::vector<std::size_t>> &vec_elementsets);
void readELEMENTALSETS(
std::ifstream& in,
std::vector<std::vector<std::size_t>>& vec_elementsets);
void setMaterialIDs(FEM_CLASS const& fem_class,
void setMaterialIDs(
FEM_CLASS const& fem_class,
FEM_DIM const& fem_dim,
std::vector<GeoLib::Polyline*>* const& lines,
std::vector<std::vector<std::size_t>> const& vec_elementsets,
std::vector<MeshLib::Element*> const& vec_elements,
std::vector<int> & material_ids);
std::vector<int>& material_ids);
};
} // IO
} // MeshLib
} // IO
} // MeshLib
#endif /* FEFLOWMESHINTERFACE_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment