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

test natural coordinates mapping for 1.5D line

parent 9d070fea
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,15 @@ public:
nodes[1] = new MeshLib::Node(0.0, 0.0, 0.0);
return new MeshLib::Line(nodes);
}
// 1.5d line
static MeshLib::Line* createY()
{
MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes];
nodes[0] = new MeshLib::Node(0.0, -1.0, 0.0);
nodes[1] = new MeshLib::Node(0.0, 1.0, 0.0);
return new MeshLib::Line(nodes);
}
};
const double TestLine2::r[dim] = {0.5};
......
......@@ -83,7 +83,7 @@ public:
vec_nodes.push_back(e->getNode(i));
}
~NumLibFemNaturalCoordinatesMappingTest()
virtual ~NumLibFemNaturalCoordinatesMappingTest()
{
for (auto itr = vec_nodes.begin(); itr!=vec_nodes.end(); ++itr )
delete *itr;
......@@ -280,4 +280,36 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckZeroVolume)
ASSERT_ARRAY_NEAR(exp_dNdx, shape.dNdx.data(), shape.dNdx.size(), this->eps);
}
TEST(NumLib, FemNaturalCoordinatesMappingLineY)
{
#ifdef OGS_USE_EIGEN
typedef Eigen::Matrix<double, 2, 1> NodalVector;
typedef Eigen::Matrix<double, 1, 2, Eigen::RowMajor> DimNodalMatrix;
typedef Eigen::Matrix<double, 1, 1, Eigen::RowMajor> DimMatrix;
typedef Eigen::Matrix<double, 2, 2, Eigen::RowMajor> GlobalDimNodalMatrix;
#endif
// Shape data type
typedef ShapeMatrices<NodalVector,DimNodalMatrix,DimMatrix,GlobalDimNodalMatrix> ShapeMatricesType;
typedef NaturalCoordinatesMapping<MeshLib::Line, ShapeLine2, ShapeMatricesType> MappingType;
double r[] = {0.5};
auto line = TestLine2::createY();
static const unsigned dim = 1;
static const unsigned e_nnodes = 2;
ShapeMatricesType shape(dim, 2, e_nnodes);
MappingType::computeShapeMatrices(*line, r, shape);
double exp_J[dim*dim]= {0.0};
for (unsigned i=0; i<dim; i++)
exp_J[i+dim*i] = 1.0;
const double eps(std::numeric_limits<double>::epsilon());
ASSERT_ARRAY_NEAR(TestLine2::nat_exp_N, shape.N.data(), shape.N.size(), eps);
ASSERT_ARRAY_NEAR(TestLine2::nat_exp_dNdr, shape.dNdr.data(), shape.dNdr.size(), eps);
ASSERT_ARRAY_NEAR(exp_J, shape.J.data(), shape.J.size(), eps);
ASSERT_ARRAY_NEAR(exp_J, shape.invJ.data(), shape.invJ.size(), eps);
ASSERT_NEAR(1.0, shape.detJ, eps);
double exp_dNdx[2*e_nnodes] = {0, 0, -0.5, 0.5};
ASSERT_ARRAY_NEAR(exp_dNdx, shape.dNdx.data(), shape.dNdx.size(), eps);
delete line;
}
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