diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp index e9298be6f61764ed0136852331f3465d4cada1f7..7555f4b8f5cba0046de1d62e65b287a69ac31047 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp +++ b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp @@ -84,8 +84,8 @@ void NodeWiseMeshPartitioner::readMetisData(const std::string& file_name_base) std::remove(fname_eparts.c_str()); } -void NodeWiseMeshPartitioner - ::partitionByMETIS(const bool is_mixed_high_order_linear_elems) +void NodeWiseMeshPartitioner::partitionByMETIS( + const bool is_mixed_high_order_linear_elems) { std::vector<MeshLib::Node*> const& nodes = _mesh->getNodes(); for (std::size_t part_id = 0; part_id < _partitions.size(); part_id++) @@ -186,8 +186,8 @@ void NodeWiseMeshPartitioner renumberNodeIndices(is_mixed_high_order_linear_elems); } -void NodeWiseMeshPartitioner::renumberNodeIndices - (const bool is_mixed_high_order_linear_elems) +void NodeWiseMeshPartitioner::renumberNodeIndices( + const bool is_mixed_high_order_linear_elems) { std::size_t node_global_id_offset = 0; // Renumber the global indices. @@ -252,7 +252,7 @@ NodeWiseMeshPartitioner::IntegerType NodeWiseMeshPartitioner::getNumberOfIntegerVariablesOfElements( const std::vector<const MeshLib::Element*>& elements) const { - // Number of material ID, element type, and number of the nodes of + // Element ID, element type, and number of the nodes of // an element of all elements in the current partition. IntegerType nmb_element_idxs = 3 * elements.size(); for (const auto* elem : elements) @@ -262,9 +262,10 @@ NodeWiseMeshPartitioner::getNumberOfIntegerVariablesOfElements( return nmb_element_idxs; } -std::tuple< std::vector<NodeWiseMeshPartitioner::IntegerType>, - std::vector<NodeWiseMeshPartitioner::IntegerType>> -NodeWiseMeshPartitioner::writeConfigDataBinary(const std::string& file_name_base) +std::tuple<std::vector<NodeWiseMeshPartitioner::IntegerType>, + std::vector<NodeWiseMeshPartitioner::IntegerType>> +NodeWiseMeshPartitioner::writeConfigDataBinary( + const std::string& file_name_base) { const std::string fname = file_name_base + "_partitioned_msh_cfg" + std::to_string(_npartitions) + ".bin"; @@ -305,10 +306,10 @@ NodeWiseMeshPartitioner::writeConfigDataBinary(const std::string& file_name_base // Update offsets num_elem_integers[loop_id] = partition.regular_elements.size() + config_data[8]; - // Offset the ending enrtry of the element integer variales of + // Offset the ending entry of the element integer variales of // the non-ghost elements of this partition in the vector of elem_info. config_data[11] += num_elem_integers[loop_id] * sizeof(IntegerType); - // Offset the ending enrtry of the element integer variales of + // Offset the ending entry of the element integer variales of // the ghost elements of this partition in the vector of elem_info. num_g_elem_integers[loop_id] = partition.ghost_elements.size() + config_data[9]; @@ -518,29 +519,6 @@ void NodeWiseMeshPartitioner::writeASCII(const std::string& file_name_base) writeNodesASCII(file_name_base); } -void NodeWiseMeshPartitioner::resetGlobalNodeIndices() -{ - for (std::size_t i = 0; i < _mesh->_nodes.size(); i++) - { - _mesh->_nodes[i]->setID(_nodes_global_ids[i]); - } - // sort - std::sort(_mesh->_nodes.begin(), _mesh->_nodes.end(), - [](const MeshLib::Node* a, const MeshLib::Node* b) { - return a->getID() < b->getID(); - }); -} - -void NodeWiseMeshPartitioner::writeGlobalMeshVTU( - const std::string& file_name_base) -{ - resetGlobalNodeIndices(); - MeshLib::IO::VtuInterface writer(_mesh.get()); - const std::string npartitions_str = std::to_string(_npartitions); - writer.writeToFile(file_name_base + "_node_id_renumbered_partitions_" + - npartitions_str + ".vtu"); -} - void NodeWiseMeshPartitioner::getElementIntegerVariables( const MeshLib::Element& elem, const std::vector<IntegerType>& local_node_ids, diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h index c1505252263b5912773eafccc2afc8a78fcbe734..40f3fc3b1adee9db02003e607d30a32a23bec3c8 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h +++ b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h @@ -64,8 +64,6 @@ public: /// interpolation void partitionByMETIS(const bool is_mixed_high_order_linear_elems); - void resetGlobalNodeIndices(); - /// Read metis data /// \param file_name_base The prefix of the file name. void readMetisData(const std::string& file_name_base); @@ -82,10 +80,6 @@ public: /// \param file_name_base The prefix of the file name. void writeBinary(const std::string& file_name_base); - /// Write the global mesh into a VTU file - /// \param file_name_base The prefix of the file name. - void writeGlobalMeshVTU(const std::string& file_name_base); - private: /// Number of partitions. IntegerType _npartitions; @@ -113,12 +107,11 @@ private: /*! Calculate the total number of integer variables of an element - vector. - Each element has three integer variables for material ID, + vector. Each element has three integer variables for element ID, element type, number of nodes of the element. Therefore the total number of the integers in an element vector is 3 * vector size + sum (number of nodes of each element) - */ + */ IntegerType getNumberOfIntegerVariablesOfElements( const std::vector<const MeshLib::Element*>& elements) const; diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/PartitionMesh.cpp b/Applications/Utils/ModelPreparation/PartitionMesh/PartitionMesh.cpp index 3b6d8acfe6459d4c1ef86fa017cce095df143f65..69f5121ccd7f5ba80842836b0fca9edcc992e0f9 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/PartitionMesh.cpp +++ b/Applications/Utils/ModelPreparation/PartitionMesh/PartitionMesh.cpp @@ -134,9 +134,6 @@ int main(int argc, char* argv[]) INFO("Write the data of partitions into binary files ..."); mesh_partitioner.writeBinary(file_name_base); } - - INFO("Write the mesh with renumbered node indices into VTU ..."); - mesh_partitioner.writeGlobalMeshVTU(file_name_base); } INFO("Total runtime: %g s.", run_timer.elapsed()); diff --git a/MeshLib/IO/MPI_IO/NodePartitionedMeshReader.h b/MeshLib/IO/MPI_IO/NodePartitionedMeshReader.h index cf302e0fd76703933c28cb89027a98100e56c5c7..26e4a9f2488938d08d69b2813271c446b294499b 100644 --- a/MeshLib/IO/MPI_IO/NodePartitionedMeshReader.h +++ b/MeshLib/IO/MPI_IO/NodePartitionedMeshReader.h @@ -76,17 +76,24 @@ private: /// A collection of integers that configure the partitioned mesh data. struct PartitionedMeshInfo { - unsigned long nodes; ///< 0: Number of all nodes of a partition, - unsigned long base_nodes; ///< 1: Number of nodes for linear elements of a parition, - unsigned long regular_elements; ///< 2: Number of non-ghost elements of a partition, - unsigned long ghost_elements; ///< 3: Number of ghost element of a partition, - unsigned long active_base_nodes; ///< 4: Number of active nodes for linear element of a parition, - unsigned long active_nodes; ///< 5: Number of all active nodes a parition, - unsigned long global_base_nodes; ///< 6: Number of nodes for linear element of global mesh, - unsigned long global_nodes; ///< 7: Number of all nodes of global mesh, - unsigned long offset[5]; ///< 8~12: Offsets of positions of partitions in the data arrays - /// (only 8 and 9 are used for ascii input) - unsigned long extra_flag; ///< 13: Reserved for extra flag. + unsigned long nodes; ///< 0: Number of all nodes of a partition, + unsigned long base_nodes; ///< 1: Number of nodes for linear + ///elements of a parition, + unsigned long regular_elements; ///< 2: Number of non-ghost elements + ///of a partition, + unsigned long + ghost_elements; ///< 3: Number of ghost element of a partition, + unsigned long active_base_nodes; ///< 4: Number of active nodes for + /// linear element of a parition, + unsigned long + active_nodes; ///< 5: Number of all active nodes a parition, + unsigned long global_base_nodes; ///< 6: Number of nodes for linear + /// element of global mesh, + unsigned long global_nodes; ///< 7: Number of all nodes of global mesh, + unsigned long offset[5]; ///< 8~12: Offsets of positions of partitions + /// in the data arrays (only 8 and 9 are used + /// for ascii input) + unsigned long extra_flag; ///< 13: Reserved for extra flag. std::size_t size() const { return 14; } unsigned long* data() { return &nodes; } diff --git a/MeshLib/Node.h b/MeshLib/Node.h index cc62d741ccdd3b46b623d989af09bb9b217b24b0..e41a3aee1768a4d1e38b972db4b105581a041cc1 100644 --- a/MeshLib/Node.h +++ b/MeshLib/Node.h @@ -73,7 +73,7 @@ public: return Node(_x[0]-v[0], _x[1]-v[1], _x[2]-v[2]); } -protected: +private: /// Update coordinates of a node. /// This method automatically also updates the areas/volumes of all connected elements. void updateCoordinates(double x, double y, double z); diff --git a/MeshLib/NodePartitionedMesh.h b/MeshLib/NodePartitionedMesh.h index f858ad3ac63691222e157309cde92c45f2054a51..0593b8c7d535201797e4c340575adb327e55cdf8 100644 --- a/MeshLib/NodePartitionedMesh.h +++ b/MeshLib/NodePartitionedMesh.h @@ -27,150 +27,143 @@ namespace MeshLib /// A subdomain mesh. class NodePartitionedMesh : public Mesh { - public: - // Copy a global mesh for the case of the thread number is one, - // i.e the gobal mesh is not partitioned. - // \param mesh The gobal mesh - explicit NodePartitionedMesh(const Mesh& mesh) - : Mesh(mesh), _global_node_ids(mesh.getNumberOfNodes()), - _n_global_base_nodes(mesh.getNumberOfBaseNodes()), - _n_global_nodes(mesh.getNumberOfNodes()), - _n_active_base_nodes(mesh.getNumberOfBaseNodes()), - _n_active_nodes(mesh.getNumberOfNodes()) +public: + // Copy a global mesh for the case of the thread number is one, + // i.e the gobal mesh is not partitioned. + // \param mesh The gobal mesh + explicit NodePartitionedMesh(const Mesh& mesh) + : Mesh(mesh), + _global_node_ids(mesh.getNumberOfNodes()), + _n_global_base_nodes(mesh.getNumberOfBaseNodes()), + _n_global_nodes(mesh.getNumberOfNodes()), + _n_active_base_nodes(mesh.getNumberOfBaseNodes()), + _n_active_nodes(mesh.getNumberOfNodes()) + { + const auto& mesh_nodes = mesh.getNodes(); + for (std::size_t i = 0; i < _nodes.size(); i++) { - const auto& mesh_nodes = mesh.getNodes(); - for (std::size_t i = 0; i < _nodes.size(); i++) + _global_node_ids[i] = _nodes[i]->getID(); + + // TODO To add copying of the connected nodes (and elements) + // in the copy constructor of class Node in order to + // drop the following lines. + auto node = _nodes[i]; + // Copy constructor of Mesh does not copy the connected + // nodes to node. + if (node->_connected_nodes.size() == 0) { - _global_node_ids[i] = _nodes[i]->getID(); - - // TODO To add copying of the connected nodes (and elements) - // in the copy constructor of class Node in order to - // drop the following lines. - auto node = _nodes[i]; - // Copy constructor of Mesh does not copy the connected - // nodes to node. - if (node->_connected_nodes.size() == 0) - { - std::copy(mesh_nodes[i]->_connected_nodes.begin(), - mesh_nodes[i]->_connected_nodes.end(), - std::back_inserter(node->_connected_nodes)); - } + std::copy(mesh_nodes[i]->_connected_nodes.begin(), + mesh_nodes[i]->_connected_nodes.end(), + std::back_inserter(node->_connected_nodes)); } } - - /*! - \brief Constructor - \param name Name assigned to the mesh. - \param nodes Vector for nodes, which storage looks like: - ||--active base nodes--|--ghost base nodes--| - --active extra nodes--|--ghost extra nodes--|| - (extra nodes: nodes for high order interpolations) - \param glb_node_ids Global IDs of nodes of a partition. - \param elements Vector for elements. Ghost elements are stored - after regular (non-ghost) elements. - \param properties Mesh property. - \param n_global_base_nodes Number of the base nodes of the global mesh. - \param n_global_nodes Number of all nodes of the global mesh. - \param n_base_nodes Number of the base nodes. - \param n_active_base_nodes Number of the active base nodes. - \param n_active_nodes Number of all active nodes. - */ - NodePartitionedMesh(const std::string &name, - const std::vector<Node*> &nodes, - const std::vector<std::size_t> &glb_node_ids, - const std::vector<Element*> &elements, - Properties properties, - const std::size_t n_global_base_nodes, - const std::size_t n_global_nodes, - const std::size_t n_base_nodes, - const std::size_t n_active_base_nodes, - const std::size_t n_active_nodes) - : Mesh(name, nodes, elements, properties, n_base_nodes), - _global_node_ids(glb_node_ids), - _n_global_base_nodes(n_global_base_nodes), - _n_global_nodes(n_global_nodes), - _n_active_base_nodes(n_active_base_nodes), - _n_active_nodes(n_active_nodes) - { - } - - /// Get the number of nodes of the global mesh for linear elements. - std::size_t getNumberOfGlobalBaseNodes() const - { - return _n_global_base_nodes; - } - - /// Get the number of all nodes of the global mesh. - std::size_t getNumberOfGlobalNodes() const - { - return _n_global_nodes; - } - - /// Get the global node ID of a node with its local ID. - std::size_t getGlobalNodeID(const std::size_t node_id) const - { - return _global_node_ids[node_id]; - } - - /// Get the number of the active nodes of the partition for linear elements. - std::size_t getNumberOfActiveBaseNodes() const - { - return _n_active_base_nodes; - } - - /// Get the number of all active nodes of the partition. - std::size_t getNumberOfActiveNodes() const - { - return _n_active_nodes; - } - - /// Check whether a node with ID of node_id is a ghost node - bool isGhostNode(const std::size_t node_id) const - { - if(node_id < _n_active_base_nodes) - return false; - else if(node_id >= _n_base_nodes && node_id < getLargestActiveNodeID() ) - return false; - else - return true; - } - - /// Get the largest ID of active nodes for higher order elements in a partition. - std::size_t getLargestActiveNodeID() const - { - return _n_base_nodes + _n_active_nodes - _n_active_base_nodes; - } - - // TODO I guess that is a simplified version of computeSparsityPattern() - /// Get the maximum number of connected nodes to node. - std::size_t getMaximumNConnectedNodesToNode() const - { - std::vector<Node *>::const_iterator it_max_ncn = std::max_element( - _nodes.cbegin(), _nodes.cend(), - [](Node const *const node_a, Node const *const node_b) - { - return (node_a->getConnectedNodes().size() < - node_b->getConnectedNodes().size()); - }); - // Return the number of connected nodes +1 for the node itself. - return (*it_max_ncn)->getConnectedNodes().size() + 1; - } - - private: - /// Global IDs of nodes of a partition - std::vector<std::size_t> _global_node_ids; - - /// Number of the nodes of the global mesh linear interpolations. - std::size_t _n_global_base_nodes; - - /// Number of all nodes of the global mesh. - std::size_t _n_global_nodes; - - /// Number of the active nodes for linear interpolations - std::size_t _n_active_base_nodes; - - /// Number of the all active nodes. - std::size_t _n_active_nodes; + } + + /*! + \brief Constructor + \param name Name assigned to the mesh. + \param nodes Vector for nodes, which storage looks like: + ||--active base nodes--|--ghost base nodes--| + --active extra nodes--|--ghost extra nodes--|| + (extra nodes: nodes for high order interpolations) + \param glb_node_ids Global IDs of nodes of a partition. + \param elements Vector for elements. Ghost elements are stored + after regular (non-ghost) elements. + \param properties Mesh property. + \param n_global_base_nodes Number of the base nodes of the global mesh. + \param n_global_nodes Number of all nodes of the global mesh. + \param n_base_nodes Number of the base nodes. + \param n_active_base_nodes Number of the active base nodes. + \param n_active_nodes Number of all active nodes. + */ + NodePartitionedMesh(const std::string& name, + const std::vector<Node*>& nodes, + const std::vector<std::size_t>& glb_node_ids, + const std::vector<Element*>& elements, + Properties properties, + const std::size_t n_global_base_nodes, + const std::size_t n_global_nodes, + const std::size_t n_base_nodes, + const std::size_t n_active_base_nodes, + const std::size_t n_active_nodes) + : Mesh(name, nodes, elements, properties, n_base_nodes), + _global_node_ids(glb_node_ids), + _n_global_base_nodes(n_global_base_nodes), + _n_global_nodes(n_global_nodes), + _n_active_base_nodes(n_active_base_nodes), + _n_active_nodes(n_active_nodes) + { + } + + /// Get the number of nodes of the global mesh for linear elements. + std::size_t getNumberOfGlobalBaseNodes() const + { + return _n_global_base_nodes; + } + + /// Get the number of all nodes of the global mesh. + std::size_t getNumberOfGlobalNodes() const { return _n_global_nodes; } + /// Get the global node ID of a node with its local ID. + std::size_t getGlobalNodeID(const std::size_t node_id) const + { + return _global_node_ids[node_id]; + } + + /// Get the number of the active nodes of the partition for linear elements. + std::size_t getNumberOfActiveBaseNodes() const + { + return _n_active_base_nodes; + } + + /// Get the number of all active nodes of the partition. + std::size_t getNumberOfActiveNodes() const { return _n_active_nodes; } + /// Check whether a node with ID of node_id is a ghost node + bool isGhostNode(const std::size_t node_id) const + { + if (node_id < _n_active_base_nodes) + return false; + else if (node_id >= _n_base_nodes && node_id < getLargestActiveNodeID()) + return false; + else + return true; + } + + /// Get the largest ID of active nodes for higher order elements in a + /// partition. + std::size_t getLargestActiveNodeID() const + { + return _n_base_nodes + _n_active_nodes - _n_active_base_nodes; + } + + // TODO I guess that is a simplified version of computeSparsityPattern() + /// Get the maximum number of connected nodes to node. + std::size_t getMaximumNConnectedNodesToNode() const + { + std::vector<Node*>::const_iterator it_max_ncn = std::max_element( + _nodes.cbegin(), _nodes.cend(), + [](Node const* const node_a, Node const* const node_b) { + return (node_a->getConnectedNodes().size() < + node_b->getConnectedNodes().size()); + }); + // Return the number of connected nodes +1 for the node itself. + return (*it_max_ncn)->getConnectedNodes().size() + 1; + } + +private: + /// Global IDs of nodes of a partition + std::vector<std::size_t> _global_node_ids; + + /// Number of the nodes of the global mesh linear interpolations. + std::size_t _n_global_base_nodes; + + /// Number of all nodes of the global mesh. + std::size_t _n_global_nodes; + + /// Number of the active nodes for linear interpolations + std::size_t _n_active_base_nodes; + + /// Number of the all active nodes. + std::size_t _n_active_nodes; }; } // namespace MeshLib diff --git a/MeshLib/PropertyVector.h b/MeshLib/PropertyVector.h index 8117734547413bee1f1ba0bf78fde533e878f534..37b285ccf9d180a1648feb82fdbb59c03594b284 100644 --- a/MeshLib/PropertyVector.h +++ b/MeshLib/PropertyVector.h @@ -22,9 +22,6 @@ namespace MeshLib { - -//template <typename T> class PropertyVector; - class PropertyVectorBase { public: @@ -86,10 +83,11 @@ public: component); } - PropertyVectorBase* clone(std::vector<std::size_t> const& exclude_positions) const + PropertyVectorBase* clone( + std::vector<std::size_t> const& exclude_positions) const { - PropertyVector<PROP_VAL_TYPE> *t(new PropertyVector<PROP_VAL_TYPE>(_property_name, - _mesh_item_type, _n_components)); + PropertyVector<PROP_VAL_TYPE>* t(new PropertyVector<PROP_VAL_TYPE>( + _property_name, _mesh_item_type, _n_components)); BaseLib::excludeObjectCopy(*this, exclude_positions, *t); return t; } @@ -220,7 +218,7 @@ public: assert(component < _n_components); assert(tuple_index < getNumberOfTuples()); const double* p = this->operator[](tuple_index); - if (p==nullptr) + if (p == nullptr) OGS_FATAL("No data found in the property vector %s " "for the tuple index %d and component %d", getPropertyName().c_str(), tuple_index, component); @@ -235,7 +233,8 @@ public: std::copy(this->cbegin(), this->cend(), std::ostream_iterator<std::size_t>(os, " ")); os << "\n\tvalues (" << _values.size() << "):\n"; - for (std::size_t k(0); k<_values.size(); k++) { + for (std::size_t k(0); k < _values.size(); k++) + { os << "val: " << *(_values[k]) << ", address: " << _values[k] << "\n"; } return os; diff --git a/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.cpp b/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.cpp index 2f99c1360cff4e955f7a0a1470d7859660a92501..be8dabcb684f031ae37efb534c4f1badef7297ed 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.cpp +++ b/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.cpp @@ -24,7 +24,6 @@ #include "MaterialLib/Fluid/FluidProperty.h" #include "MaterialLib/PorousMedium/Porosity/Porosity.h" #include "MaterialLib/PorousMedium/Storage/Storage.h" -#include "MaterialLib/Fluid/FluidProperties/CreateFluidProperties.h" #include "MaterialLib/Fluid/FluidPropertyHeaders.h" #include "MaterialLib/PorousMedium/PorousPropertyHeaders.h"