Skip to content
Snippets Groups Projects
Unverified Commit 79498920 authored by Tom Fischer's avatar Tom Fischer Committed by GitHub
Browse files

Merge pull request #2219 from endJunction/WarningAndErrorFixes

Warning and error fixes
parents 60b1ee2b cfaf528e
No related branches found
No related tags found
No related merge requests found
......@@ -430,8 +430,8 @@ bool TetGenInterface::parseElements(std::ifstream& ins,
bool region_attribute) const
{
std::string line;
auto* ids(static_cast<std::size_t*>(
alloca(sizeof(std::size_t) * n_nodes_per_tet)));
std::vector<std::size_t> ids(n_nodes_per_tet);
elements.reserve(n_tets);
materials.reserve(n_tets);
......@@ -492,8 +492,9 @@ bool TetGenInterface::parseElements(std::ifstream& ins,
}
// insert new element into vector
auto** tet_nodes = new MeshLib::Node*[4];
for (unsigned k(0); k<4; k++) {
tet_nodes[k] = nodes[ids[k]];
for (int n = 0; n < 4; n++)
{
tet_nodes[n] = nodes[ids[n]];
}
elements.push_back (new MeshLib::Tet(tet_nodes));
materials.push_back(region);
......
......@@ -347,6 +347,7 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> &
if (!ply_found)
{
ERR("Error in Polyline::contructPolylineFromSegments() - Not all segments are connected.");
delete new_ply;
new_ply = nullptr;
break;
}
......
......@@ -487,6 +487,7 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem,
prism_nodes[3] = nodes[org_elem->getNode(this->lutHexDiametralNode(org_elem->getNodeIDinElement(face->getNode(1))))->getID()];
prism_nodes[4] = nodes[org_elem->getNode(this->lutHexDiametralNode(org_elem->getNodeIDinElement(face->getNode(2))))->getID()];
prism_nodes[5] = nodes[org_elem->getNode(org_elem->getNodeIDinElement(face->getNode(0)))->getID()];
new_elements.push_back(new MeshLib::Prism(prism_nodes));
delete face;
return 1;
}
......
......@@ -102,12 +102,20 @@ MeshLib::Mesh* MeshLayerMapper::createStaticLayers(MeshLib::Mesh const& mesh, st
e_nodes[j] = new_nodes[node_id+nNodes];
e_nodes[j+nElemNodes] = new_nodes[node_id];
}
// extrude triangles to prism
if (sfc_elem->getGeomType() == MeshLib::MeshElemType::TRIANGLE)
new_elems.push_back (new MeshLib::Prism(e_nodes));
// extrude quads to hexes
{
// extrude triangles to prism
new_elems.push_back(new MeshLib::Prism(e_nodes));
}
else if (sfc_elem->getGeomType() == MeshLib::MeshElemType::QUAD)
new_elems.push_back (new MeshLib::Hex(e_nodes));
{
// extrude quads to hexes
new_elems.push_back(new MeshLib::Hex(e_nodes));
}
else
{
OGS_FATAL("MeshLayerMapper: Unknown element type to extrude.");
}
materials->push_back(mat_id);
}
}
......@@ -127,14 +135,13 @@ bool MeshLayerMapper::createRasterLayers(
return false;
}
auto* top(new MeshLib::Mesh(mesh));
auto top = std::make_unique<MeshLib::Mesh>(mesh);
if (!layerMapping(*top, *rasters.back(), noDataReplacementValue))
return false;
auto* bottom(new MeshLib::Mesh(mesh));
auto bottom = std::make_unique<MeshLib::Mesh>(mesh);
if (!layerMapping(*bottom, *rasters[0], 0))
{
delete top;
return false;
}
......@@ -153,13 +160,11 @@ bool MeshLayerMapper::createRasterLayers(
std::vector<MeshLib::Node*> const& nodes = bottom->getNodes();
for (MeshLib::Node* node : nodes)
_nodes.push_back(new MeshLib::Node(*node));
delete bottom;
// add the other layers
for (std::size_t i=0; i<nLayers-1; ++i)
addLayerToMesh(*top, i, *rasters[i+1]);
delete top;
return true;
}
......
......@@ -57,9 +57,10 @@ createNonuniformNeumannBoundaryCondition(
boundary_mesh.getProperties().getPropertyVector<std::size_t>(
mapping_to_bulk_nodes_property);
if (!(mapping_to_bulk_nodes && mapping_to_bulk_nodes->getMeshItemType() ==
MeshLib::MeshItemType::Node) &&
mapping_to_bulk_nodes->getNumberOfComponents() == 1)
if (mapping_to_bulk_nodes == nullptr ||
mapping_to_bulk_nodes->getMeshItemType() !=
MeshLib::MeshItemType::Node ||
mapping_to_bulk_nodes->getNumberOfComponents() != 1)
{
OGS_FATAL("Field `%s' is not set up properly.",
mapping_to_bulk_nodes_property.c_str());
......
......@@ -82,6 +82,7 @@ TEST(GeoLib, SearchNearestPointInGrid)
pnts.push_back(new GeoLib::Point(0.0,0.0,0.0));
GeoLib::Grid<GeoLib::Point> *grid(nullptr);
ASSERT_NO_THROW(grid = new GeoLib::Grid<GeoLib::Point>(pnts.begin(), pnts.end()));
ASSERT_NE(grid, nullptr);
GeoLib::Point p0(0,10,10);
GeoLib::Point* res(grid->getNearestPoint(p0));
......
......@@ -85,14 +85,14 @@ TEST_F(PolygonTest, isPntInPolygonCheckCorners)
TEST_F(PolygonTest, isPntInPolygonCheckPointsRestOnPolygonEdges)
{
for (std::size_t k(0); k<_pnts.size()-1; k++) {
for (double t(0.0); t<1.0; t+=0.001) {
EXPECT_TRUE(_polygon->isPntInPolygon(
GeoLib::Point(
(*_pnts[k])[0] + t*((*_pnts[k+1])[0]-(*_pnts[k])[0]),
(*_pnts[k])[1] + t*((*_pnts[k+1])[1]-(*_pnts[k])[1]),
(*_pnts[k])[2] + t*((*_pnts[k+1])[2]-(*_pnts[k])[2])
))
);
double t = 0;
while (t < 1.0)
{
EXPECT_TRUE(_polygon->isPntInPolygon(GeoLib::Point(
(*_pnts[k])[0] + t * ((*_pnts[k + 1])[0] - (*_pnts[k])[0]),
(*_pnts[k])[1] + t * ((*_pnts[k + 1])[1] - (*_pnts[k])[1]),
(*_pnts[k])[2] + t * ((*_pnts[k + 1])[2] - (*_pnts[k])[2]))));
t += 0.001;
}
}
}
......
......@@ -23,13 +23,14 @@ TEST(MeshLib, UniqueMeshId)
//
// Test mesh counter increments.
//
Mesh* m1 = new Mesh("second", std::vector<Node*>(), std::vector<Element*>());
auto m1 = std::make_unique<Mesh>("second", std::vector<Node*>(),
std::vector<Element*>());
ASSERT_EQ(counter_value + std::size_t(1), m1->getID());
Mesh m2("third", std::vector<Node*>(), std::vector<Element*>());
ASSERT_EQ(counter_value + std::size_t(2), m2.getID());
delete m1;
m1.reset();
ASSERT_EQ(counter_value + std::size_t(2), m2.getID());
Mesh m3("fourth", std::vector<Node*>(), std::vector<Element*>());
......
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