std::size_t ElementValueModification::setByElementType(MeshLib::Mesh &mesh, MeshElemType ele_type, int const new_value) { auto* const property_value_vector = mesh.getProperties().getPropertyVector<int>("MaterialIDs"); if (!property_value_vector) { return 0; } std::vector<MeshLib::Element*> const& elements(mesh.getElements()); std::size_t cnt(0); for (std::size_t k(0); k<elements.size(); k++) { if (elements[k]->getGeomType()!=ele_type) continue; (*property_value_vector)[k] = new_value; cnt++; } return cnt; }
bool ElementValueModification::replace(MeshLib::Mesh &mesh, std::string const& property_name, int const old_value, int const new_value, bool replace_if_exists) { auto* const property_value_vec = mesh.getProperties().getPropertyVector<int>(property_name); if (!property_value_vec) { return false; } const std::size_t n_property_tuples( property_value_vec->getNumberOfTuples()); if (!replace_if_exists) { for (std::size_t i = 0; i < n_property_tuples; ++i) { if ((*property_value_vec)[i] == new_value) { WARN( "ElementValueModification::replaceElementValue() " "- Replacement value \"%d\" is already taken, " "no changes have been made.", new_value); return false; } } } for (std::size_t i = 0; i < n_property_tuples; ++i) { if ((*property_value_vec)[i] == old_value) (*property_value_vec)[i] = new_value; } return true; }
PostProcessTool::PostProcessTool( MeshLib::Mesh const& org_mesh, std::vector<MeshLib::Node*> const& vec_fracture_nodes, std::vector<MeshLib::Element*> const& vec_fracutre_matrix_elements) :_org_mesh(org_mesh) { if (!org_mesh.getProperties().hasPropertyVector("displacement") || !org_mesh.getProperties().hasPropertyVector("displacement_jump1") || !org_mesh.getProperties().hasPropertyVector("levelset1") ) { OGS_FATAL("The given mesh does not have relevant properties"); } // clone nodes and elements std::vector<MeshLib::Node*> new_nodes(MeshLib::copyNodeVector(org_mesh.getNodes())); std::vector<MeshLib::Element*> new_eles( MeshLib::copyElementVector(org_mesh.getElements(), new_nodes)); // duplicate fracture nodes for (auto const* org_node : vec_fracture_nodes) { auto duplicated_node = new MeshLib::Node(org_node->getCoords(), new_nodes.size()); new_nodes.push_back(duplicated_node); _map_dup_newNodeIDs[org_node->getID()] = duplicated_node->getID(); } // split elements using the new duplicated nodes auto prop_levelset = org_mesh.getProperties().getPropertyVector<double>("levelset1"); for (auto const* org_e : vec_fracutre_matrix_elements) { // only matrix elements if (org_e->getDimension() != org_mesh.getDimension()) continue; auto const eid = org_e->getID(); // keep original if the element has levelset=0 if ((*prop_levelset)[eid] == 0) continue; // replace fracture nodes with duplicated ones MeshLib::Element* e = new_eles[eid]; for (unsigned i=0; i<e->getNumberOfNodes(); i++) { // only fracture nodes auto itr = _map_dup_newNodeIDs.find(e->getNodeIndex(i)); if (itr == _map_dup_newNodeIDs.end()) continue; // check if a node belongs to the particular fracture group auto itr2 = std::find_if(vec_fracture_nodes.begin(), vec_fracture_nodes.end(), [&](MeshLib::Node const*node) { return node->getID()==e->getNodeIndex(i);}); if (itr2 == vec_fracture_nodes.end()) continue; e->setNode(i, new_nodes[itr->second]); } } // new mesh _output_mesh.reset(new MeshLib::Mesh(org_mesh.getName(), new_nodes, new_eles)); createProperties<int>(); createProperties<double>(); copyProperties<int>(); copyProperties<double>(); calculateTotalDisplacement(); }
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(); }
std::unique_ptr<MeshLib::Mesh> convertToLinearMesh(MeshLib::Mesh const& org_mesh, std::string const& new_mesh_name) { std::vector<MeshLib::Node*> vec_new_nodes = MeshLib::copyNodeVector(MeshLib::getBaseNodes(org_mesh.getElements())); // create new elements with the quadratic nodes std::vector<MeshLib::Element*> vec_new_eles; for (MeshLib::Element const* e : org_mesh.getElements()) { if (e->getCellType() == MeshLib::CellType::LINE3) { vec_new_eles.push_back(createLinearElement<MeshLib::Line>( e, vec_new_nodes)); } else if (e->getCellType() == MeshLib::CellType::QUAD8) { vec_new_eles.push_back(createLinearElement<MeshLib::Quad>( e, vec_new_nodes)); } else if (e->getCellType() == MeshLib::CellType::TRI6) { vec_new_eles.push_back(createLinearElement<MeshLib::Tri>( e, vec_new_nodes)); } else if (e->getCellType() == MeshLib::CellType::HEX20) { vec_new_eles.push_back(createLinearElement<MeshLib::Hex>( e, vec_new_nodes)); } else if (e->getCellType() == MeshLib::CellType::TET10) { vec_new_eles.push_back(createLinearElement<MeshLib::Tet>( e, vec_new_nodes)); } else { OGS_FATAL("Mesh element type %s is not supported", MeshLib::CellType2String(e->getCellType()).c_str()); } } auto new_mesh = std::make_unique<MeshLib::Mesh>( new_mesh_name, vec_new_nodes, vec_new_eles, org_mesh.getProperties().excludeCopyProperties( std::vector<MeshLib::MeshItemType>(1, MeshLib::MeshItemType::Node))); // copy property vectors for nodes MeshLib::Properties const& src_properties = org_mesh.getProperties(); for (auto name : src_properties.getPropertyVectorNames()) { if (!src_properties.existsPropertyVector<double>(name)) { continue; } auto const* src_prop = src_properties.getPropertyVector<double>(name); if (src_prop->getMeshItemType() != MeshLib::MeshItemType::Node) { continue; } auto const n_src_comp = src_prop->getNumberOfComponents(); auto new_prop = new_mesh->getProperties().createNewPropertyVector<double>( name, MeshLib::MeshItemType::Node, n_src_comp); new_prop->resize(new_mesh->getNumberOfNodes() * n_src_comp); // copy only base node values for (unsigned i=0; i<org_mesh.getNumberOfBaseNodes(); i++) { for (int j = 0; j < n_src_comp; j++) { (*new_prop)[i * n_src_comp + j] = (*src_prop)[i * n_src_comp + j]; } } } return new_mesh; }
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); std::vector<int> new_mat_ids; { if (mesh.getProperties().existsPropertyVector<int>("MaterialIDs")) { auto ids = mesh.getProperties().getPropertyVector<int>("MaterialIDs"); new_mat_ids.reserve(ids->size()); std::copy(ids->cbegin(), ids->cend(), std::back_inserter(new_mat_ids)); } } int max_matID(0); if (!new_mat_ids.empty()) max_matID = *(std::max_element(new_mat_ids.cbegin(), new_mat_ids.cend())); 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 opt_mat_pv = new_mesh->getProperties().createNewPropertyVector<int>( "MaterialIDs", MeshLib::MeshItemType::Cell); if (opt_mat_pv) { auto & mat_pv = *opt_mat_pv; mat_pv.reserve(new_mat_ids.size()); std::copy(new_mat_ids.cbegin(), new_mat_ids.cend(), std::back_inserter(mat_pv)); } return new_mesh; }
void ThermoMechanicsProcess<DisplacementDim>::initializeConcreteProcess( NumLib::LocalToGlobalIndexMap const& dof_table, MeshLib::Mesh const& mesh, unsigned const integration_order) { ProcessLib::SmallDeformation::createLocalAssemblers< DisplacementDim, ThermoMechanicsLocalAssembler>( mesh.getElements(), dof_table, _local_assemblers, mesh.isAxiallySymmetric(), integration_order, _process_data); // TODO move the two data members somewhere else. // for extrapolation of secondary variables std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{ *_mesh_subset_all_nodes}; _local_to_global_index_map_single_component.reset( new NumLib::LocalToGlobalIndexMap( std::move(all_mesh_subsets_single_component), // by location order is needed for output NumLib::ComponentOrder::BY_LOCATION)); _secondary_variables.addSecondaryVariable( "sigma", makeExtrapolator( MathLib::KelvinVector::KelvinVectorType< DisplacementDim>::RowsAtCompileTime, getExtrapolator(), _local_assemblers, &ThermoMechanicsLocalAssemblerInterface::getIntPtSigma)); _secondary_variables.addSecondaryVariable( "epsilon", makeExtrapolator( MathLib::KelvinVector::KelvinVectorType< DisplacementDim>::RowsAtCompileTime, getExtrapolator(), _local_assemblers, &ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilon)); // Set initial conditions for integration point data. for (auto const& ip_writer : _integration_point_writer) { // Find the mesh property with integration point writer's name. auto const& name = ip_writer->name(); if (!mesh.getProperties().existsPropertyVector<double>(name)) { continue; } auto const& mesh_property = *mesh.getProperties().template getPropertyVector<double>(name); // The mesh property must be defined on integration points. if (mesh_property.getMeshItemType() != MeshLib::MeshItemType::IntegrationPoint) { continue; } auto const ip_meta_data = getIntegrationPointMetaData(mesh, name); // Check the number of components. if (ip_meta_data.n_components != mesh_property.getNumberOfComponents()) { OGS_FATAL( "Different number of components in meta data (%d) than in " "the integration point field data for '%s': %d.", ip_meta_data.n_components, name.c_str(), mesh_property.getNumberOfComponents()); } // Now we have a properly named vtk's field data array and the // corresponding meta data. std::size_t position = 0; for (auto& local_asm : _local_assemblers) { std::size_t const integration_points_read = local_asm->setIPDataInitialConditions( name, &mesh_property[position], ip_meta_data.integration_order); if (integration_points_read == 0) { OGS_FATAL( "No integration points read in the integration point " "initial conditions set function."); } position += integration_points_read * ip_meta_data.n_components; } } }
void SmallDeformationNonlocalProcess<DisplacementDim>:: initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const& dof_table, MeshLib::Mesh const& mesh, unsigned const integration_order) { // Reusing local assembler creation code. ProcessLib::SmallDeformation::createLocalAssemblers< DisplacementDim, SmallDeformationNonlocalLocalAssembler>( mesh.getElements(), dof_table, _local_assemblers, mesh.isAxiallySymmetric(), integration_order, _process_data); // TODO move the two data members somewhere else. // for extrapolation of secondary variables std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{ *_mesh_subset_all_nodes}; _local_to_global_index_map_single_component = std::make_unique<NumLib::LocalToGlobalIndexMap>( std::move(all_mesh_subsets_single_component), // by location order is needed for output NumLib::ComponentOrder::BY_LOCATION); Process::_secondary_variables.addSecondaryVariable( "sigma", makeExtrapolator(MathLib::KelvinVector::KelvinVectorType< DisplacementDim>::RowsAtCompileTime, getExtrapolator(), _local_assemblers, &LocalAssemblerInterface::getIntPtSigma)); Process::_secondary_variables.addSecondaryVariable( "epsilon", makeExtrapolator(MathLib::KelvinVector::KelvinVectorType< DisplacementDim>::RowsAtCompileTime, getExtrapolator(), _local_assemblers, &LocalAssemblerInterface::getIntPtEpsilon)); Process::_secondary_variables.addSecondaryVariable( "eps_p_V", makeExtrapolator(1, getExtrapolator(), _local_assemblers, &LocalAssemblerInterface::getIntPtEpsPV)); Process::_secondary_variables.addSecondaryVariable( "eps_p_D_xx", makeExtrapolator(1, getExtrapolator(), _local_assemblers, &LocalAssemblerInterface::getIntPtEpsPDXX)); Process::_secondary_variables.addSecondaryVariable( "damage", makeExtrapolator(1, getExtrapolator(), _local_assemblers, &LocalAssemblerInterface::getIntPtDamage)); GlobalExecutor::executeMemberOnDereferenced( &LocalAssemblerInterface::nonlocal, _local_assemblers, _local_assemblers); // Set initial conditions for integration point data. for (auto const& ip_writer : _integration_point_writer) { auto const& name = ip_writer->name(); // First check the field data, which is used for restart. if (mesh.getProperties().existsPropertyVector<double>(name)) { auto const& mesh_property = *mesh.getProperties().template getPropertyVector<double>(name); // The mesh property must be defined on integration points. if (mesh_property.getMeshItemType() != MeshLib::MeshItemType::IntegrationPoint) { continue; } auto const ip_meta_data = getIntegrationPointMetaData(mesh, name); // Check the number of components. if (ip_meta_data.n_components != mesh_property.getNumberOfComponents()) { OGS_FATAL( "Different number of components in meta data (%d) than in " "the integration point field data for '%s': %d.", ip_meta_data.n_components, name.c_str(), mesh_property.getNumberOfComponents()); } // Now we have a properly named vtk's field data array and the // corresponding meta data. std::size_t position = 0; for (auto& local_asm : _local_assemblers) { std::size_t const integration_points_read = local_asm->setIPDataInitialConditions( name, &mesh_property[position], ip_meta_data.integration_order); if (integration_points_read == 0) { OGS_FATAL( "No integration points read in the integration point " "initial conditions set function."); } position += integration_points_read * ip_meta_data.n_components; } } else if (mesh.getProperties().existsPropertyVector<double>(name + "_ic")) { // Try to find cell data with '_ic' suffix auto const& mesh_property = *mesh.getProperties().template getPropertyVector<double>(name + "_ic"); if (mesh_property.getMeshItemType() != MeshLib::MeshItemType::Cell) { continue; } // Now we have a vtk's cell data array containing the initial // conditions for the corresponding integration point writer. // For each assembler use the single cell value for all // integration points. for (std::size_t i = 0; i < _local_assemblers.size(); ++i) { auto& local_asm = _local_assemblers[i]; std::vector<double> value( &mesh_property[i], &mesh_property[i] + mesh_property.getNumberOfComponents()); // TODO (naumov) Check sizes / read size / etc. // OR reconstruct dimensions from size / component = // ip_points local_asm->setIPDataInitialConditionsFromCellData(name, value); } } } }
std::unique_ptr<Process> createLiquidFlowProcess( MeshLib::Mesh& mesh, std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler, std::vector<ProcessVariable> const& variables, std::vector<std::unique_ptr<ParameterBase>> const& parameters, unsigned const integration_order, BaseLib::ConfigTree const& config) { //! \ogs_file_param{process__type} config.checkConfigParameter("type", "LIQUID_FLOW"); DBUG("Create LiquidFlowProcess."); // Process variable. auto process_variables = findProcessVariables( variables, config, {//! \ogs_file_param_special{process__LIQUID_FLOW__process_variables__process_variable} "process_variable"}); SecondaryVariableCollection secondary_variables; NumLib::NamedFunctionCaller named_function_caller({"LiquidFlow_pressure"}); ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); // Get the gravity vector for the Darcy velocity //! \ogs_file_param{process__LIQUID_FLOW__darcy_gravity} auto const& darcy_g_config = config.getConfigSubtree("darcy_gravity"); const int gravity_axis_id_input = //! \ogs_file_param_special{process__LIQUID_FLOW__darcy_gravity_axis_id} darcy_g_config.getConfigParameter<int>("axis_id"); assert(gravity_axis_id_input < static_cast<int>(mesh.getDimension())); const double g = //! \ogs_file_param_special{process__LIQUID_FLOW__darcy_gravity_g} darcy_g_config.getConfigParameter<double>("g"); assert(g >= 0.); const int gravity_axis_id = (g == 0.) ? -1 : gravity_axis_id_input; //! \ogs_file_param{process__LIQUID_FLOW__material_property} auto const& mat_config = config.getConfigSubtree("material_property"); auto const& mat_ids = mesh.getProperties().getPropertyVector<int>("MaterialIDs"); if (mat_ids) { INFO("The liquid flow is in heterogeneous porous media."); const bool has_material_ids = true; return std::unique_ptr<Process>{new LiquidFlowProcess{ mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(secondary_variables), std::move(named_function_caller), *mat_ids, has_material_ids, gravity_axis_id, g, mat_config}}; } else { INFO("The liquid flow is in homogeneous porous media."); MeshLib::Properties dummy_property; // For a reference argument of LiquidFlowProcess(...). auto const& dummy_property_vector = dummy_property.createNewPropertyVector<int>( "MaterialIDs", MeshLib::MeshItemType::Cell, 1); // Since dummy_property_vector is only visible in this function, // the following constant, has_material_ids, is employed to indicate // that material_ids does not exist. const bool has_material_ids = false; return std::unique_ptr<Process>{new LiquidFlowProcess{ mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(secondary_variables), std::move(named_function_caller), *dummy_property_vector, has_material_ids, gravity_axis_id, g, mat_config}}; } }
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); }