Skip to content
Snippets Groups Projects
Commit 0c56ed89 authored by Tom Fischer's avatar Tom Fischer
Browse files

Pass flag for computing element neighbors

parent 62d13142
No related branches found
No related tags found
No related merge requests found
Showing
with 56 additions and 25 deletions
......@@ -339,7 +339,8 @@ MeshLib::Mesh* GMSInterface::readMesh(const std::string& filename)
ERR("Ignoring Material IDs information (does not match number of "
"elements).");
}
return new MeshLib::Mesh(mesh_name, nodes, elements, properties);
return new MeshLib::Mesh(mesh_name, nodes, elements,
true /* compute_element_neighbors */, properties);
}
} // namespace FileIO
......@@ -373,7 +373,8 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname)
}
MeshLib::Mesh* mesh(new MeshLib::Mesh(
BaseLib::extractBaseNameWithoutExtension(fname), nodes, elements));
BaseLib::extractBaseNameWithoutExtension(fname), nodes, elements,
true /* compute_element_neighbors */));
auto* const material_ids =
mesh->getProperties().createNewPropertyVector<int>(
......
......@@ -569,7 +569,9 @@ MeshLib::Mesh* createMesh(std::ifstream& in, DataType type,
std::for_each(nodes.begin(), nodes.end(),
[](MeshLib::Node* n) { (*n)[2] *= -1; });
}
return new MeshLib::Mesh(mesh_name, nodes, elems, mesh_prop);
return new MeshLib::Mesh(mesh_name, nodes, elems,
true /* compute_element_neighbors */,
mesh_prop);
}
ERR("Error parsing {:s} {:s}.", dataType2ShortString(type), mesh_name);
BaseLib::cleanupVectorElements(nodes, elems);
......
......@@ -186,7 +186,8 @@ std::unique_ptr<MeshLib::Mesh> GocadSGridReader::getMesh() const
DBUG("Creating mesh from Gocad SGrid.");
std::unique_ptr<MeshLib::Mesh> mesh(new MeshLib::Mesh(
BaseLib::extractBaseNameWithoutExtension(_fname), nodes, elements));
BaseLib::extractBaseNameWithoutExtension(_fname), nodes, elements,
true /* compute_element_neighbors */));
addGocadPropertiesToMesh(*mesh);
DBUG("Mesh created.");
......@@ -785,8 +786,9 @@ std::unique_ptr<MeshLib::Mesh> GocadSGridReader::getFaceSetMesh(
}
std::string const mesh_name("FaceSet-" + std::to_string(face_set_number));
return std::make_unique<MeshLib::Mesh>(mesh_name, face_set_nodes,
face_set_elements);
return std::make_unique<MeshLib::Mesh>(
mesh_name, face_set_nodes, face_set_elements,
true /* compute_element_neighbors */);
}
void GocadSGridReader::addFaceSetQuad(
......
......@@ -269,7 +269,8 @@ MeshLib::Mesh* TetGenInterface::readTetGenMesh(std::string const& nodes_fname,
const std::string mesh_name(
BaseLib::extractBaseNameWithoutExtension(nodes_fname));
return new MeshLib::Mesh(mesh_name, nodes, elements, properties);
return new MeshLib::Mesh(mesh_name, nodes, elements,
true /* compute_element_neighbors */, properties);
}
bool TetGenInterface::readNodesFromStream(std::ifstream& ins,
......
......@@ -372,7 +372,8 @@ int main(int argc, char* argv[])
// The Node pointers of 'merged_nodes' and Element pointers of
// 'regular_elements' are shared with 'meshes', the partitioned meshes.
MeshLib::Mesh merged_mesh =
MeshLib::Mesh("pvtu_merged_mesh", merged_nodes, regular_elements);
MeshLib::Mesh("pvtu_merged_mesh", merged_nodes, regular_elements,
true /* compute_element_neighbors */);
auto const& properties = meshes[0]->getProperties();
......
......@@ -207,6 +207,7 @@ int main(int argc, char* argv[])
// is implemented are copied
MeshLib::Mesh reordered_mesh{
"reordered_mesh", reordered_nodes, reordered_elements,
false /* compute_element_neighbors */,
original_properties.excludeCopyProperties(exclude_property_vectors)};
auto& properties = reordered_mesh.getProperties();
......
......@@ -252,7 +252,8 @@ int main(int argc, char* argv[])
}
}
MeshLib::Mesh const result("result", new_nodes, new_elems, props);
MeshLib::Mesh const result("result", new_nodes, new_elems,
true /* compute_element_neighbors */, props);
MeshLib::IO::VtuInterface vtu(&result);
vtu.writeToFile(output_name);
#ifdef USE_PETSC
......
......@@ -74,7 +74,8 @@ std::unique_ptr<MeshLib::Mesh> appendLinesAlongPolylines(
// generate a mesh
const std::string name = mesh.getName() + "_with_lines";
auto new_mesh =
std::make_unique<MeshLib::Mesh>(name, vec_new_nodes, vec_new_eles);
std::make_unique<MeshLib::Mesh>(name, vec_new_nodes, vec_new_eles,
true /* compute_element_neighbors */);
auto new_material_ids =
new_mesh->getProperties().createNewPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell);
......
......@@ -367,7 +367,7 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name)
MeshLib::Mesh* mesh(new MeshLib::Mesh(
BaseLib::extractBaseNameWithoutExtension(file_name), nodes,
elements));
elements, true /* compute_element_neighbors */));
auto* const material_ids =
mesh->getProperties().createNewPropertyVector<int>(
......
......@@ -229,7 +229,8 @@ MeshLib::Mesh* VtkMeshConverter::convertUnstructuredGrid(
elements[i] = elem;
}
MeshLib::Mesh* mesh = new MeshLib::Mesh(mesh_name, nodes, elements);
MeshLib::Mesh* mesh = new MeshLib::Mesh(
mesh_name, nodes, elements, true /* compute_element_neighbors */);
convertScalarArrays(*grid, *mesh);
return mesh;
......
......@@ -41,7 +41,8 @@ NodePartitionedMesh::NodePartitionedMesh(
const std::size_t n_regular_nodes,
std::vector<std::size_t>&& n_regular_base_nodes_at_rank,
std::vector<std::size_t>&& n_regular_high_order_nodes_at_rank)
: Mesh(name, nodes, elements, properties),
: Mesh(name, nodes, elements, true /* compute_element_neighbors */,
properties),
_global_node_ids(glb_node_ids),
_n_global_base_nodes(n_global_base_nodes),
_n_global_nodes(n_global_nodes),
......
......@@ -76,7 +76,8 @@ std::unique_ptr<MeshLib::Mesh> createMeshFromElementSelection(
nodes_map | ranges::views::keys | ranges::to<std::vector>;
auto mesh = std::make_unique<MeshLib::Mesh>(
std::move(mesh_name), std::move(element_nodes), std::move(elements));
std::move(mesh_name), std::move(element_nodes), std::move(elements),
true /* compute_element_neighbors */);
assert(mesh != nullptr);
addPropertyToMesh(*mesh, getBulkIDString(MeshLib::MeshItemType::Cell),
......
......@@ -164,7 +164,8 @@ MeshLib::Mesh* addLayerToMesh(MeshLib::Mesh const& mesh, double thickness,
subsfc_nodes, *sfc_elements[k], *node_id_pv, subsfc_sfc_id_map));
}
auto new_mesh = new MeshLib::Mesh(name, subsfc_nodes, subsfc_elements);
auto new_mesh = new MeshLib::Mesh(name, subsfc_nodes, subsfc_elements,
true /* compute_element_neighbors */);
if (!mesh.getProperties().existsPropertyVector<int>("MaterialIDs"))
{
......
......@@ -115,6 +115,7 @@ std::unique_ptr<MeshLib::Mesh> convertToLinearMesh(
auto new_mesh = std::make_unique<MeshLib::Mesh>(
new_mesh_name, new_mesh_nodes, vec_new_eles,
true /* compute_element_neighbors */,
mesh.getProperties().excludeCopyProperties(
std::vector<MeshLib::MeshItemType>(1,
MeshLib::MeshItemType::Node)));
......
......@@ -73,8 +73,9 @@ std::unique_ptr<MeshLib::Mesh> createFlippedMesh(MeshLib::Mesh const& mesh)
createFlippedElement(*elems[i], new_nodes).release());
}
return std::make_unique<MeshLib::Mesh>("FlippedElementMesh", new_nodes,
new_elems, mesh.getProperties());
return std::make_unique<MeshLib::Mesh>(
"FlippedElementMesh", new_nodes, new_elems,
true /* compute_element_neighbors */, mesh.getProperties());
}
} // namespace MeshToolsLib
......@@ -1083,6 +1083,7 @@ MeshLib::Mesh* MeshRevision::simplifyMesh(const std::string& new_mesh_name,
if (!new_elements.empty())
{
return new MeshLib::Mesh(new_mesh_name, new_nodes, new_elements,
true /* compute_element_neighbors */,
new_properties);
}
......
......@@ -88,6 +88,7 @@ MeshLib::Mesh* removeElements(
{
MeshLib::Mesh* new_mesh =
new MeshLib::Mesh(new_mesh_name, new_nodes, new_elems,
true /* compute_element_neighbors */,
mesh.getProperties().excludeCopyProperties(
removed_element_ids, removed_node_ids));
return new_mesh;
......@@ -167,6 +168,7 @@ MeshLib::Mesh* removeNodes(const MeshLib::Mesh& mesh,
{
MeshLib::Mesh* new_mesh =
new MeshLib::Mesh(new_mesh_name, new_nodes, new_elems,
true /* compute_element_neighbors */,
mesh.getProperties().excludeCopyProperties(
removed_element_ids, del_nodes_idx));
return new_mesh;
......
......@@ -89,7 +89,11 @@ std::unique_ptr<MeshLib::Mesh> LayeredMeshGenerator::getMesh(
}
std::unique_ptr<MeshLib::Mesh> result(
new MeshLib::Mesh(mesh_name, _nodes, _elements, properties));
new MeshLib::Mesh(mesh_name,
_nodes,
_elements,
true /* compute_element_neighbors */,
properties));
MeshLib::NodeSearch ns(*result);
if (ns.searchUnused() > 0)
{
......
......@@ -193,7 +193,8 @@ MeshLib::Mesh* MeshGenerator::generateLineMesh(const BaseLib::ISubdivision& div,
elements.push_back(new MeshLib::Line({nodes[i], nodes[i + 1]}));
}
return new MeshLib::Mesh(mesh_name, nodes, elements);
return new MeshLib::Mesh(mesh_name, nodes, elements,
true /* compute_element_neighbors */);
}
MeshLib::Mesh* MeshGenerator::generateRegularQuadMesh(
......@@ -275,7 +276,8 @@ MeshLib::Mesh* MeshGenerator::generateRegularQuadMesh(
}
}
return new MeshLib::Mesh(mesh_name, nodes, elements);
return new MeshLib::Mesh(mesh_name, nodes, elements,
true /* compute_element_neighbors */);
}
MeshLib::Mesh* MeshGenerator::generateRegularHexMesh(
......@@ -382,7 +384,8 @@ MeshLib::Mesh* MeshGenerator::generateRegularHexMesh(
}
}
return new MeshLib::Mesh(mesh_name, nodes, elements);
return new MeshLib::Mesh(mesh_name, nodes, elements,
true /* compute_element_neighbors */);
}
MeshLib::Mesh* MeshGenerator::generateRegularPyramidMesh(
......@@ -479,7 +482,8 @@ MeshLib::Mesh* MeshGenerator::generateRegularPyramidMesh(
}
}
}
return new MeshLib::Mesh(mesh_name, nodes, elements);
return new MeshLib::Mesh(mesh_name, nodes, elements,
true /* compute_element_neighbors */);
}
MeshLib::Mesh* MeshGenerator::generateRegularTriMesh(
......@@ -564,7 +568,8 @@ MeshLib::Mesh* MeshGenerator::generateRegularTriMesh(
}
}
return new MeshLib::Mesh(mesh_name, nodes, elements);
return new MeshLib::Mesh(mesh_name, nodes, elements,
true /* compute_element_neighbors */);
}
MeshLib::Mesh* MeshGenerator::generateRegularPrismMesh(
......@@ -735,7 +740,8 @@ MeshLib::Mesh* MeshGenerator::generateRegularTetMesh(
}
}
return new MeshLib::Mesh(mesh_name, nodes, elements);
return new MeshLib::Mesh(mesh_name, nodes, elements,
true /* compute_element_neighbors */);
}
MeshLib::Mesh* MeshGenerator::createSurfaceMesh(
......@@ -775,7 +781,8 @@ MeshLib::Mesh* MeshGenerator::createSurfaceMesh(
}
}
return new MeshLib::Mesh(mesh_name, nodes, sfc_eles);
return new MeshLib::Mesh(mesh_name, nodes, sfc_eles,
true /* compute_element_neighbors */);
}
} // namespace MeshToolsLib
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