std::unique_ptr<PythonBoundaryCondition> createPythonBoundaryCondition( BaseLib::ConfigTree const& config, MeshLib::Mesh const& boundary_mesh, NumLib::LocalToGlobalIndexMap const& dof_table, std::size_t bulk_mesh_id, int const variable_id, int const component_id, unsigned const integration_order, unsigned const shapefunction_order, unsigned const global_dim) { //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__type} config.checkConfigParameter("type", "Python"); //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__Python__bc_object} auto const bc_object = config.getConfigParameter<std::string>("bc_object"); //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__Python__flush_stdout} auto const flush_stdout = config.getConfigParameter("flush_stdout", false); // Evaluate Python code in scope of main module pybind11::object scope = pybind11::module::import("__main__").attr("__dict__"); if (!scope.contains(bc_object)) OGS_FATAL( "Function `%s' is not defined in the python script file, or there " "was no python script file specified.", bc_object.c_str()); auto* bc = scope[bc_object.c_str()] .cast<PythonBoundaryConditionPythonSideInterface*>(); if (variable_id >= static_cast<int>(dof_table.getNumberOfVariables()) || component_id >= dof_table.getNumberOfVariableComponents(variable_id)) { OGS_FATAL( "Variable id or component id too high. Actual values: (%d, %d), " "maximum values: (%d, %d).", variable_id, component_id, dof_table.getNumberOfVariables(), dof_table.getNumberOfVariableComponents(variable_id)); } // In case of partitioned mesh the boundary could be empty, i.e. there is no // boundary condition. #ifdef USE_PETSC // This can be extracted to createBoundaryCondition() but then the config // parameters are not read and will cause an error. // TODO (naumov): Add a function to ConfigTree for skipping the tags of the // subtree and move the code up in createBoundaryCondition(). if (boundary_mesh.getDimension() == 0 && boundary_mesh.getNumberOfNodes() == 0 && boundary_mesh.getNumberOfElements() == 0) { return nullptr; } #endif // USE_PETSC return std::make_unique<PythonBoundaryCondition>( PythonBoundaryConditionData{ bc, dof_table, bulk_mesh_id, dof_table.getGlobalComponent(variable_id, component_id), boundary_mesh}, integration_order, shapefunction_order, global_dim, flush_stdout); }
bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double eps) { if (mesh.getDimension() != 2) { ERR ("Mesh to geometry conversion is only working for 2D meshes."); return false; } // nodes to points conversion std::string mesh_name(mesh.getName()); { auto points = std::make_unique<std::vector<GeoLib::Point*>>(); points->reserve(mesh.getNumberOfNodes()); for (auto node_ptr : mesh.getNodes()) points->push_back(new GeoLib::Point(*node_ptr, node_ptr->getID())); geo_objects.addPointVec(std::move(points), mesh_name, nullptr, eps); } const std::vector<std::size_t> id_map (geo_objects.getPointVecObj(mesh_name)->getIDMap()); // elements to surface triangles conversion std::string const mat_name ("MaterialIDs"); auto bounds (MeshInformation::getValueBounds<int>(mesh, mat_name)); const unsigned nMatGroups(bounds.second-bounds.first+1); auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>(); sfcs->reserve(nMatGroups); auto const& points = *geo_objects.getPointVec(mesh_name); for (unsigned i=0; i<nMatGroups; ++i) sfcs->push_back(new GeoLib::Surface(points)); const std::vector<MeshLib::Element*> &elements = mesh.getElements(); const std::size_t nElems (mesh.getNumberOfElements()); MeshLib::PropertyVector<int> const*const materialIds = mesh.getProperties().existsPropertyVector<int>("MaterialIDs") ? mesh.getProperties().getPropertyVector<int>("MaterialIDs") : nullptr; for (unsigned i=0; i<nElems; ++i) { auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first); MeshLib::Element* e (elements[i]); if (e->getGeomType() == MeshElemType::TRIANGLE) (*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]); if (e->getGeomType() == MeshElemType::QUAD) { (*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]); (*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(2)], id_map[e->getNodeIndex(3)]); } // all other element types are ignored (i.e. lines) } std::for_each(sfcs->begin(), sfcs->end(), [](GeoLib::Surface* sfc){ if (sfc->getNumberOfTriangles()==0) delete sfc; sfc = nullptr;}); auto sfcs_end = std::remove(sfcs->begin(), sfcs->end(), nullptr); sfcs->erase(sfcs_end, sfcs->end()); geo_objects.addSurfaceVec(std::move(sfcs), mesh_name); return true; }
std::unique_ptr<DirichletBoundaryCondition> createDirichletBoundaryCondition( BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh, NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id, int const component_id, const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters) { DBUG("Constructing DirichletBoundaryCondition from config."); //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__type} config.checkConfigParameter("type", "Dirichlet"); //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__Dirichlet__parameter} auto const param_name = config.getConfigParameter<std::string>("parameter"); DBUG("Using parameter %s", param_name.c_str()); auto& param = findParameter<double>(param_name, parameters, 1); // In case of partitioned mesh the boundary could be empty, i.e. there is no // boundary condition. #ifdef USE_PETSC // This can be extracted to createBoundaryCondition() but then the config // parameters are not read and will cause an error. // TODO (naumov): Add a function to ConfigTree for skipping the tags of the // subtree and move the code up in createBoundaryCondition(). if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 && bc_mesh.getNumberOfElements() == 0) { return nullptr; } #endif // USE_PETSC return std::make_unique<DirichletBoundaryCondition>( param, bc_mesh, dof_table_bulk, variable_id, component_id); }
// Creates a PropertyVector<unsigned> and maps it into a vtkDataArray-equivalent TEST(MeshLibMappedPropertyVector, Unsigned) { const std::size_t mesh_size = 5; const double length = 1.0; MeshLib::Mesh* mesh = MeshLib::MeshGenerator::generateRegularHexMesh(length, mesh_size); ASSERT_TRUE(mesh != nullptr); const std::size_t number_of_tuples(mesh_size*mesh_size*mesh_size); std::string const prop_name("TestProperty"); auto* const properties = mesh->getProperties().createNewPropertyVector<unsigned>( prop_name, MeshLib::MeshItemType::Cell); properties->resize(number_of_tuples); std::iota(properties->begin(), properties->end(), 0); vtkNew<MeshLib::VtkMappedPropertyVectorTemplate<unsigned> > dataArray; dataArray->SetPropertyVector(*properties); ASSERT_EQ(dataArray->GetNumberOfComponents(), 1); ASSERT_EQ(dataArray->GetNumberOfTuples(), number_of_tuples); ASSERT_EQ(dataArray->GetValueReference(0), 0); double* range = dataArray->GetRange(0); ASSERT_EQ(range[0], 0); ASSERT_EQ(range[1], 0 + mesh->getNumberOfElements() - 1); delete mesh; }
std::unique_ptr<RobinBoundaryCondition> createRobinBoundaryCondition( BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh, NumLib::LocalToGlobalIndexMap const& dof_table, int const variable_id, int const component_id, unsigned const integration_order, unsigned const shapefunction_order, unsigned const global_dim, std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters) { DBUG("Constructing RobinBcConfig from config."); //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__type} config.checkConfigParameter("type", "Robin"); //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__Robin__alpha} auto const alpha_name = config.getConfigParameter<std::string>("alpha"); //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__Robin__u_0} auto const u_0_name = config.getConfigParameter<std::string>("u_0"); auto const& alpha = ParameterLib::findParameter<double>(alpha_name, parameters, 1); auto const& u_0 = ParameterLib::findParameter<double>(u_0_name, parameters, 1); // In case of partitioned mesh the boundary could be empty, i.e. there is no // boundary condition. #ifdef USE_PETSC // This can be extracted to createBoundaryCondition() but then the config // parameters are not read and will cause an error. // TODO (naumov): Add a function to ConfigTree for skipping the tags of the // subtree and move the code up in createBoundaryCondition(). if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 && bc_mesh.getNumberOfElements() == 0) { return nullptr; } #endif // USE_PETSC return std::make_unique<RobinBoundaryCondition>( integration_order, shapefunction_order, dof_table, variable_id, component_id, global_dim, bc_mesh, RobinBoundaryConditionData{alpha, u_0}); }
/// Adds the integration point data and creates meta data for it. /// /// Returns meta data for the written integration point data. static ProcessLib::IntegrationPointMetaData addIntegrationPointData( MeshLib::Mesh& mesh, ProcessLib::IntegrationPointWriter const& writer) { auto const& ip_values = writer.values(/*t, x, dof_table*/); assert(ip_values.size() == mesh.getNumberOfElements()); // create field data and fill it with nodal values, and an offsets cell // array indicating where the cell's integration point data starts. auto& field_data = *MeshLib::getOrCreateMeshProperty<double>( mesh, writer.name(), MeshLib::MeshItemType::IntegrationPoint, writer.numberOfComponents()); field_data.clear(); for (const auto& element_ip_values : ip_values) { std::copy(element_ip_values.begin(), element_ip_values.end(), std::back_inserter(field_data)); } return {writer.name(), writer.numberOfComponents(), writer.integrationOrder()}; }
int main (int argc, char* argv[]) { ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Converts VTK mesh into OGS mesh.", ' ', "0.1"); TCLAP::ValueArg<std::string> mesh_in("i", "mesh-input-file", "the name of the file containing the input mesh", true, "", "file name of input mesh"); cmd.add(mesh_in); TCLAP::ValueArg<std::string> mesh_out("o", "mesh-output-file", "the name of the file the mesh will be written to", true, "", "file name of output mesh"); cmd.add(mesh_out); cmd.parse(argc, argv); MeshLib::Mesh* mesh (MeshLib::IO::VtuInterface::readVTUFile(mesh_in.getValue())); INFO("Mesh read: %d nodes, %d elements.", mesh->getNumberOfNodes(), mesh->getNumberOfElements()); MeshLib::IO::Legacy::MeshIO meshIO; meshIO.setMesh(mesh); meshIO.writeToFile(mesh_out.getValue()); return EXIT_SUCCESS; }
std::unique_ptr<MeshLib::Mesh> appendLinesAlongPolylines( const MeshLib::Mesh& mesh, const GeoLib::PolylineVec& ply_vec) { // copy existing nodes and elements std::vector<MeshLib::Node*> vec_new_nodes = MeshLib::copyNodeVector(mesh.getNodes()); std::vector<MeshLib::Element*> vec_new_eles = MeshLib::copyElementVector(mesh.getElements(), vec_new_nodes); auto const material_ids = materialIDs(mesh); int const max_matID = material_ids ? *(std::max_element(begin(*material_ids), end(*material_ids))) : 0; std::vector<int> new_mat_ids; const std::size_t n_ply (ply_vec.size()); // for each polyline for (std::size_t k(0); k < n_ply; k++) { const GeoLib::Polyline* ply = (*ply_vec.getVector())[k]; // search nodes on the polyline MeshGeoToolsLib::MeshNodesAlongPolyline mshNodesAlongPoly( mesh, *ply, mesh.getMinEdgeLength() * 0.5, MeshGeoToolsLib::SearchAllNodes::Yes); auto &vec_nodes_on_ply = mshNodesAlongPoly.getNodeIDs(); if (vec_nodes_on_ply.empty()) { std::string ply_name; ply_vec.getNameOfElementByID(k, ply_name); INFO("No nodes found on polyline %s", ply_name.c_str()); continue; } // add line elements for (std::size_t i=0; i<vec_nodes_on_ply.size()-1; i++) { std::array<MeshLib::Node*, 2> element_nodes; element_nodes[0] = vec_new_nodes[vec_nodes_on_ply[i]]; element_nodes[1] = vec_new_nodes[vec_nodes_on_ply[i+1]]; vec_new_eles.push_back( new MeshLib::Line(element_nodes, vec_new_eles.size())); new_mat_ids.push_back(max_matID+k+1); } } // 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); auto new_material_ids = new_mesh->getProperties().createNewPropertyVector<int>( "MaterialIDs", MeshLib::MeshItemType::Cell); if (!new_material_ids) { OGS_FATAL("Could not create MaterialIDs cell vector in new mesh."); } new_material_ids->reserve(new_mesh->getNumberOfElements()); if (material_ids != nullptr) { std::copy(begin(*material_ids), end(*material_ids), std::back_inserter(*new_material_ids)); } else { new_material_ids->resize(mesh.getNumberOfElements()); } std::copy(begin(new_mat_ids), end(new_mat_ids), std::back_inserter(*new_material_ids)); return new_mesh; }
void getFractureMatrixDataInMesh( MeshLib::Mesh const& mesh, std::vector<MeshLib::Element*>& vec_matrix_elements, std::vector<MeshLib::Element*>& vec_fracture_elements, std::vector<MeshLib::Element*>& vec_fracture_matrix_elements, std::vector<MeshLib::Node*>& vec_fracture_nodes ) { IsCrackTip isCrackTip(mesh); // get vectors of matrix elements and fracture elements vec_matrix_elements.reserve(mesh.getNumberOfElements()); for (MeshLib::Element* e : mesh.getElements()) { if (e->getDimension() == mesh.getDimension()) vec_matrix_elements.push_back(e); else vec_fracture_elements.push_back(e); } DBUG("-> found total %d matrix elements and %d fracture elements", vec_matrix_elements.size(), vec_fracture_elements.size()); // get a vector of fracture nodes for (MeshLib::Element* e : vec_fracture_elements) { for (unsigned i=0; i<e->getNumberOfNodes(); i++) { if (isCrackTip(*e->getNode(i))) continue; vec_fracture_nodes.push_back(const_cast<MeshLib::Node*>(e->getNode(i))); } } std::sort(vec_fracture_nodes.begin(), vec_fracture_nodes.end(), [](MeshLib::Node* node1, MeshLib::Node* node2) { return (node1->getID() < node2->getID()); } ); vec_fracture_nodes.erase( std::unique(vec_fracture_nodes.begin(), vec_fracture_nodes.end()), vec_fracture_nodes.end()); DBUG("-> found %d nodes on the fracture", vec_fracture_nodes.size()); // create a vector fracture elements and connected matrix elements, // which are passed to a DoF table // first, collect matrix elements for (MeshLib::Element *e : vec_fracture_elements) { for (unsigned i=0; i<e->getNumberOfBaseNodes(); i++) { MeshLib::Node const* node = e->getNode(i); if (isCrackTip(*node)) continue; for (unsigned j=0; j<node->getNumberOfElements(); j++) { // only matrix elements if (node->getElement(j)->getDimension() == mesh.getDimension()-1) continue; vec_fracture_matrix_elements.push_back(const_cast<MeshLib::Element*>(node->getElement(j))); } } } std::sort(vec_fracture_matrix_elements.begin(), vec_fracture_matrix_elements.end(), [](MeshLib::Element* p1, MeshLib::Element* p2) { return (p1->getID() < p2->getID()); } ); vec_fracture_matrix_elements.erase( std::unique(vec_fracture_matrix_elements.begin(), vec_fracture_matrix_elements.end()), vec_fracture_matrix_elements.end()); // second, append fracture elements vec_fracture_matrix_elements.insert( vec_fracture_matrix_elements.end(), vec_fracture_elements.begin(), vec_fracture_elements.end()); }
void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh) { this->clearView(); QList<QVariant> mesh_name; mesh_name << "Name:" << QString::fromStdString(mesh.getName()) << "" << "" << ""; TreeItem* name_item = new TreeItem(mesh_name, _rootItem); _rootItem->appendChild(name_item); QList<QVariant> nodes_number; nodes_number << "#Nodes: " << QString::number(mesh.getNumberOfNodes()) << "" << ""; TreeItem* nodes_item = new TreeItem(nodes_number, _rootItem); _rootItem->appendChild(nodes_item); QList<QVariant> elements_number; elements_number << "#Elements: " << QString::number(mesh.getNumberOfElements()) << "" << ""; TreeItem* elements_item = new TreeItem(elements_number, _rootItem); _rootItem->appendChild(elements_item); const std::array<QString, 7> n_element_names = {{ "Lines:", "Triangles:", "Quads:", "Tetrahedra:", "Hexahedra:", "Pyramids:", "Prisms:" }}; const std::array<unsigned, 7>& n_element_types (MeshLib::MeshInformation::getNumberOfElementTypes(mesh)); for (std::size_t i=0; i<n_element_types.size(); ++i) { if (n_element_types[i]) { QList<QVariant> elements_number; elements_number << n_element_names[i] << QString::number(n_element_types[i]) << "" << ""; TreeItem* type_item = new TreeItem(elements_number, elements_item); elements_item->appendChild(type_item); } } QList<QVariant> bounding_box; bounding_box << "Bounding Box" << "" << "" << ""; TreeItem* aabb_item = new TreeItem(bounding_box, _rootItem); _rootItem->appendChild(aabb_item); const GeoLib::AABB aabb (MeshLib::MeshInformation::getBoundingBox(mesh)); auto const& min = aabb.getMinPoint(); auto const& max = aabb.getMaxPoint(); QList<QVariant> min_aabb; min_aabb << "Min:" << QString::number(min[0], 'f') << QString::number(min[1], 'f') << QString::number(min[2], 'f'); TreeItem* min_item = new TreeItem(min_aabb, aabb_item); aabb_item->appendChild(min_item); QList<QVariant> max_aabb; max_aabb << "Max:" << QString::number(max[0], 'f') << QString::number(max[1], 'f') << QString::number(max[2], 'f'); TreeItem* max_item = new TreeItem(max_aabb, aabb_item); aabb_item->appendChild(max_item); QList<QVariant> edges; edges << "Edge Length: " << "[" + QString::number(mesh.getMinEdgeLength(), 'f') + "," << QString::number(mesh.getMaxEdgeLength(), 'f') + "]" << ""; TreeItem* edge_item = new TreeItem(edges, _rootItem); _rootItem->appendChild(edge_item); std::vector<std::string> const& vec_names (mesh.getProperties().getPropertyVectorNames()); for (std::size_t i=0; i<vec_names.size(); ++i) { QList<QVariant> array_info; array_info << QString::fromStdString(vec_names[i]) + ": "; auto vec_bounds (MeshLib::MeshInformation::getValueBounds<int>(mesh, vec_names[i])); if (vec_bounds.second != std::numeric_limits<int>::max()) array_info << "[" + QString::number(vec_bounds.first) + "," << QString::number(vec_bounds.second) + "]" << ""; else { auto vec_bounds (MeshLib::MeshInformation::getValueBounds<double>(mesh, vec_names[i])); if (vec_bounds.second != std::numeric_limits<double>::max()) array_info << "[" + QString::number(vec_bounds.first) + "," << QString::number(vec_bounds.second) + "]" << ""; } if (array_info.size() == 1) array_info << "[ ?" << "? ]" << ""; TreeItem* vec_item = new TreeItem(array_info, _rootItem); _rootItem->appendChild(vec_item); } reset(); }
void MeshLayerMapper::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned layer_id, GeoLib::Raster const& raster) { const unsigned pyramid_base[3][4] = { {1, 3, 4, 2}, // Point 4 missing {2, 4, 3, 0}, // Point 5 missing {0, 3, 4, 1}, // Point 6 missing }; std::size_t const nNodes = dem_mesh.getNumberOfNodes(); std::vector<MeshLib::Node*> const& nodes = dem_mesh.getNodes(); int const last_layer_node_offset = layer_id * nNodes; // add nodes for new layer for (std::size_t i=0; i<nNodes; ++i) _nodes.push_back(getNewLayerNode(*nodes[i], *_nodes[last_layer_node_offset + i], raster, _nodes.size())); std::vector<MeshLib::Element*> const& elems = dem_mesh.getElements(); std::size_t const nElems (dem_mesh.getNumberOfElements()); for (std::size_t i=0; i<nElems; ++i) { MeshLib::Element* elem (elems[i]); if (elem->getGeomType() != MeshLib::MeshElemType::TRIANGLE) continue; unsigned node_counter(3), missing_idx(0); std::array<MeshLib::Node*, 6> new_elem_nodes; for (unsigned j=0; j<3; ++j) { new_elem_nodes[j] = _nodes[_nodes[last_layer_node_offset + elem->getNodeIndex(j)]->getID()]; new_elem_nodes[node_counter] = (_nodes[last_layer_node_offset + elem->getNodeIndex(j) + nNodes]); if (new_elem_nodes[j]->getID() != new_elem_nodes[node_counter]->getID()) node_counter++; else missing_idx = j; } switch (node_counter) { case 6: _elements.push_back(new MeshLib::Prism(new_elem_nodes)); _materials.push_back(layer_id); break; case 5: std::array<MeshLib::Node*, 5> pyramid_nodes; pyramid_nodes[0] = new_elem_nodes[pyramid_base[missing_idx][0]]; pyramid_nodes[1] = new_elem_nodes[pyramid_base[missing_idx][1]]; pyramid_nodes[2] = new_elem_nodes[pyramid_base[missing_idx][2]]; pyramid_nodes[3] = new_elem_nodes[pyramid_base[missing_idx][3]]; pyramid_nodes[4] = new_elem_nodes[missing_idx]; _elements.push_back(new MeshLib::Pyramid(pyramid_nodes)); _materials.push_back(layer_id); break; case 4: std::array<MeshLib::Node*, 4> tet_nodes; std::copy(new_elem_nodes.begin(), new_elem_nodes.begin() + node_counter, tet_nodes.begin()); _elements.push_back(new MeshLib::Tet(tet_nodes)); _materials.push_back(layer_id); break; default: continue; } } }
void CreateStructuredGridDialog::accept() { if (inputIsEmpty()) return; if ((this->xLengthEdit->text().toDouble() <= 0) || (this->yLengthEdit->text().toDouble() <= 0) || (this->zLengthEdit->text().toDouble() <= 0)) { OGSError::box("Length needs to be larger than 0."); return; } if ((this->xElemEdit->text().toDouble() <= 0) || (this->yElemEdit->text().toDouble() <= 0) || (this->zElemEdit->text().toDouble() <= 0)) { OGSError::box("Number of elements needs to be larger than 0."); return; } GeoLib::Point const origin(this->xOriginEdit->text().toDouble(), this->yOriginEdit->text().toDouble(), this->zOriginEdit->text().toDouble()); std::string const name (this->meshNameEdit->text().toStdString()); MeshLib::Mesh* mesh (nullptr); if (this->lineButton->isChecked()) if (this->meshExtentButton->isChecked()) mesh = MeshLib::MeshGenerator::generateLineMesh( this->xLengthEdit->text().toDouble(), this->xElemEdit->text().toInt(), origin, name); else mesh = MeshLib::MeshGenerator::generateLineMesh( this->xElemEdit->text().toInt(), this->xLengthEdit->text().toDouble(), origin, name); else if (this->triButton->isChecked()) if (this->meshExtentButton->isChecked()) mesh = MeshLib::MeshGenerator::generateRegularTriMesh( this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), origin, name); else mesh = MeshLib::MeshGenerator::generateRegularTriMesh( this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), origin, name); else if (this->quadButton->isChecked()) if (this->meshExtentButton->isChecked()) mesh = MeshLib::MeshGenerator::generateRegularQuadMesh( this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), origin, name); else mesh = MeshLib::MeshGenerator::generateRegularQuadMesh( this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), origin, name); else if (this->prismButton->isChecked()) if (this->meshExtentButton->isChecked()) mesh = MeshLib::MeshGenerator::generateRegularPrismMesh( this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), this->zLengthEdit->text().toDouble(), this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), this->zElemEdit->text().toInt(), origin, name); else mesh = MeshLib::MeshGenerator::generateRegularPrismMesh( this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), this->zLengthEdit->text().toDouble(), this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), this->zElemEdit->text().toInt(), origin, name); else if (this->hexButton->isChecked()) if (this->meshExtentButton->isChecked()) mesh = MeshLib::MeshGenerator::generateRegularHexMesh( this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), this->zLengthEdit->text().toDouble(), this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), this->zElemEdit->text().toInt(), origin, name); else mesh = MeshLib::MeshGenerator::generateRegularHexMesh( this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), this->zElemEdit->text().toInt(), this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), this->zLengthEdit->text().toDouble(), origin, name); if (mesh == nullptr) { OGSError::box("Error creating mesh."); return; } boost::optional<MeshLib::PropertyVector<int>&> mat_ids ( mesh->getProperties().createNewPropertyVector<int>("MaterialIDs", MeshLib::MeshItemType::Cell)); mat_ids->reserve(mesh->getNumberOfElements()); std::fill_n(std::back_inserter(*mat_ids), mesh->getNumberOfElements(), 0); emit meshAdded(mesh); this->done(QDialog::Accepted); }