Skip to content
Snippets Groups Projects
Commit 68d30c7a authored by Dmitri Naumov's avatar Dmitri Naumov Committed by Tom Fischer
Browse files

[MeL] Use Point3d. Remove private fcts from iface.

Use Point3d instead of a Node in
ElementCoordinatesMappingLocal.

Move local functions to cpp in detail namespace.
parent 0016e38d
No related branches found
No related tags found
No related merge requests found
...@@ -16,48 +16,28 @@ ...@@ -16,48 +16,28 @@
#include "MeshLib/Elements/Element.h" #include "MeshLib/Elements/Element.h"
#include "MeshLib/Node.h" #include "MeshLib/Node.h"
#include "MathLib/MathTools.h" #include "MathLib/MathTools.h"
#include "MathLib/Point3d.h"
#include "MathLib/Vector3.h" #include "MathLib/Vector3.h"
namespace MeshLib namespace detail
{ {
ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal( /// rotate points to local coordinates
const Element& e, void rotateToLocal(
const CoordinateSystem &global_coords) const MeshLib::RotationMatrix &matR2local,
: _coords(global_coords), _matR2global(3,3) std::vector<MathLib::Point3d*> &vec_nodes)
{ {
assert(e.getDimension() <= global_coords.getDimension()); for (auto node : vec_nodes)
for(unsigned i = 0; i < e.getNNodes(); i++) node->setCoords((matR2local*(*node)).getCoords());
_vec_nodes.push_back(new MeshLib::Node(*(e.getNode(i))));
getRotationMatrixToGlobal(e, global_coords, _vec_nodes, _matR2global);
#ifdef OGS_USE_EIGEN
rotateToLocal(_matR2global.transpose(), _vec_nodes);
#else
RotationMatrix* m(_matR2global.transpose());
rotateToLocal(*m, _vec_nodes);
delete m;
#endif
}
ElementCoordinatesMappingLocal::~ElementCoordinatesMappingLocal()
{
for (auto p : _vec_nodes) delete p;
} }
void ElementCoordinatesMappingLocal::rotateToLocal( /// get a rotation matrix to the global coordinates
const RotationMatrix &matR2local, /// it computes R in x=R*x' where x is original coordinates and x' is local coordinates
std::vector<MeshLib::Node*> &vec_nodes) const void getRotationMatrixToGlobal(
{ const MeshLib::Element &e,
for (MeshLib::Node* node : vec_nodes) const MeshLib::CoordinateSystem &global_coords,
node->setCoords((matR2local*static_cast<MathLib::Point3d>(*node)).getCoords()); const std::vector<MathLib::Point3d*> &vec_nodes,
} MeshLib::RotationMatrix &matR)
void ElementCoordinatesMappingLocal::getRotationMatrixToGlobal(
const Element &e,
const CoordinateSystem &global_coords,
const std::vector<MeshLib::Node*> &vec_nodes,
RotationMatrix &matR) const
{ {
const std::size_t global_dim = global_coords.getDimension(); const std::size_t global_dim = global_coords.getDimension();
...@@ -76,7 +56,9 @@ void ElementCoordinatesMappingLocal::getRotationMatrixToGlobal( ...@@ -76,7 +56,9 @@ void ElementCoordinatesMappingLocal::getRotationMatrixToGlobal(
// get plane normal // get plane normal
MathLib::Vector3 plane_normal; MathLib::Vector3 plane_normal;
double d; double d;
GeoLib::getNewellPlane (vec_nodes, plane_normal, d); //std::tie(plane_normal, d) = GeoLib::getNewellPlane(vec_nodes);
GeoLib::getNewellPlane(vec_nodes, plane_normal, d);
// compute a rotation matrix to XY // compute a rotation matrix to XY
GeoLib::computeRotationMatrixToXY(plane_normal, matR); GeoLib::computeRotationMatrixToXY(plane_normal, matR);
// set a transposed matrix // set a transposed matrix
...@@ -84,5 +66,34 @@ void ElementCoordinatesMappingLocal::getRotationMatrixToGlobal( ...@@ -84,5 +66,34 @@ void ElementCoordinatesMappingLocal::getRotationMatrixToGlobal(
} }
} }
} // namespace detail
namespace MeshLib
{
ElementCoordinatesMappingLocal::~ElementCoordinatesMappingLocal()
{
for (auto p : _vec_nodes) delete p;
}
ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal(
const Element& e,
const CoordinateSystem &global_coords)
: _coords(global_coords), _matR2global(3,3)
{
assert(e.getDimension() <= global_coords.getDimension());
_vec_nodes.reserve(e.getNNodes());
for(unsigned i = 0; i < e.getNNodes(); i++)
_vec_nodes.push_back(new MathLib::Point3d(*static_cast<MathLib::Point3d const*>(e.getNode(i))));
detail::getRotationMatrixToGlobal(e, global_coords, _vec_nodes, _matR2global);
#ifdef OGS_USE_EIGEN
detail::rotateToLocal(_matR2global.transpose(), _vec_nodes);
#else
RotationMatrix* m(_matR2global.transpose());
detail::rotateToLocal(*m, _vec_nodes);
delete m;
#endif
}
} // MeshLib } // MeshLib
...@@ -54,27 +54,17 @@ public: ...@@ -54,27 +54,17 @@ public:
const CoordinateSystem getGlobalCoordinateSystem() const { return _coords; } const CoordinateSystem getGlobalCoordinateSystem() const { return _coords; }
/// return mapped coordinates of the node /// return mapped coordinates of the node
const MeshLib::Node* getMappedCoordinates(size_t node_id) const MathLib::Point3d const& getMappedCoordinates(std::size_t node_id) const
{ {
return _vec_nodes[node_id]; return *_vec_nodes[node_id];
} }
/// return a rotation matrix converting to global coordinates /// return a rotation matrix converting to global coordinates
const RotationMatrix& getRotationMatrixToGlobal() const {return _matR2global;} const RotationMatrix& getRotationMatrixToGlobal() const {return _matR2global;}
private:
/// rotate points to local coordinates
void rotateToLocal(const RotationMatrix &matR2local, std::vector<MeshLib::Node*> &vec_pt) const;
/// get a rotation matrix to the global coordinates
/// it computes R in x=R*x' where x is original coordinates and x' is local coordinates
void getRotationMatrixToGlobal(
const Element &e, const CoordinateSystem &coordinate_system,
const std::vector<MeshLib::Node*> &vec_pt, RotationMatrix &matR2original) const;
private: private:
const CoordinateSystem _coords; const CoordinateSystem _coords;
std::vector<MeshLib::Node*> _vec_nodes; std::vector<MathLib::Point3d*> _vec_nodes;
RotationMatrix _matR2global; RotationMatrix _matR2global;
}; };
......
...@@ -67,7 +67,7 @@ inline void computeMappingMatrices( ...@@ -67,7 +67,7 @@ inline void computeMappingMatrices(
//jacobian: J=[dx/dr dy/dr // dx/ds dy/ds] //jacobian: J=[dx/dr dy/dr // dx/ds dy/ds]
for (std::size_t k=0; k<nnodes; k++) { for (std::size_t k=0; k<nnodes; k++) {
const MeshLib::Node& mapped_pt = *ele_local_coord.getMappedCoordinates(k); const MathLib::Point3d& mapped_pt = ele_local_coord.getMappedCoordinates(k);
// outer product of dNdr and mapped_pt for a particular node // outer product of dNdr and mapped_pt for a particular node
for (std::size_t i_r=0; i_r<dim; i_r++) { for (std::size_t i_r=0; i_r<dim; i_r++) {
for (std::size_t j_x=0; j_x<dim; j_x++) { for (std::size_t j_x=0; j_x<dim; j_x++) {
......
...@@ -141,7 +141,7 @@ void debugOutput(MeshLib::Element *ele, MeshLib::ElementCoordinatesMappingLocal ...@@ -141,7 +141,7 @@ void debugOutput(MeshLib::Element *ele, MeshLib::ElementCoordinatesMappingLocal
// check if using the rotation matrix results in the original coordinates // check if using the rotation matrix results in the original coordinates
#define CHECK_COORDS(ele, mapping)\ #define CHECK_COORDS(ele, mapping)\
for (unsigned ii=0; ii<ele->getNNodes(); ii++) {\ for (unsigned ii=0; ii<ele->getNNodes(); ii++) {\
MathLib::Point3d global(matR*static_cast<MathLib::Point3d>(*mapping.getMappedCoordinates(ii)));\ MathLib::Point3d global(matR*mapping.getMappedCoordinates(ii));\
const double eps(std::numeric_limits<double>::epsilon());\ const double eps(std::numeric_limits<double>::epsilon());\
ASSERT_ARRAY_NEAR(&(*ele->getNode(ii))[0], global.getCoords(), 3u, eps);\ ASSERT_ARRAY_NEAR(&(*ele->getNode(ii))[0], global.getCoords(), 3u, eps);\
} }
......
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