25 return std::any_of(vec_nodes.begin(), vec_nodes.end(),
27 { return node->getID() == node_id; });
31 std::vector<std::pair<std::size_t, std::vector<int>>>
const&
36 std::find_if(vec_nodeID_matIDs.begin(), vec_nodeID_matIDs.end(),
37 [&](std::pair<std::size_t, std::vector<int>>
const& entry)
38 { return entry.first == nodeID; });
39 assert(itr != vec_nodeID_matIDs.end());
46 std::vector<int>
const& vec_fracture_mat_IDs,
47 std::vector<std::vector<MeshLib::Node*>>
const& vec_vec_fracture_nodes,
48 std::vector<std::vector<MeshLib::Element*>>
const&
49 vec_vec_fracture_matrix_elements,
50 std::vector<std::pair<std::size_t, std::vector<int>>>
const&
51 vec_branch_nodeID_matIDs,
52 std::vector<std::pair<std::size_t, std::vector<int>>>
const&
53 vec_junction_nodeID_matIDs)
60 OGS_FATAL(
"The given mesh does not have relevant properties");
64 std::vector<MeshLib::Node*> new_nodes(
66 std::vector<MeshLib::Element*> new_eles(
70 for (
auto const& vec_fracture_nodes : vec_vec_fracture_nodes)
72 for (
auto const* org_node : vec_fracture_nodes)
74 auto duplicated_node =
76 new_nodes.push_back(duplicated_node);
78 duplicated_node->getID());
82 for (
auto& entry : vec_junction_nodeID_matIDs)
84 auto* org_node = org_mesh.
getNode(entry.first);
85 auto duplicated_node =
87 new_nodes.push_back(duplicated_node);
89 duplicated_node->getID());
93 for (
unsigned fracture_id = 0;
94 fracture_id < vec_vec_fracture_matrix_elements.size();
97 auto const frac_matid = vec_fracture_mat_IDs[fracture_id];
98 auto const& vec_fracture_matrix_elements =
99 vec_vec_fracture_matrix_elements[fracture_id];
100 auto const& vec_fracture_nodes = vec_vec_fracture_nodes[fracture_id];
102 "levelset" + std::to_string(fracture_id + 1));
103 for (
auto const* org_e : vec_fracture_matrix_elements)
111 auto const eid = org_e->getID();
113 if ((*prop_levelset)[eid] <= 0)
134 const auto& dup_newNodeIDs = itr->second;
137 unsigned new_node_id = 0;
138 if (dup_newNodeIDs.size() == 1)
141 new_node_id = dup_newNodeIDs[0];
143 else if (dup_newNodeIDs.size() == 2)
147 vec_branch_nodeID_matIDs, node_id);
149 br_matids, frac_matid);
151 auto const frac2_id =
153 assert(frac2_id != std::numeric_limits<std::size_t>::max());
154 auto prop_levelset2 =
156 "levelset" + std::to_string(frac2_id + 1));
158 if ((*prop_levelset2)[eid] <= 0)
163 else if ((*prop_levelset2)[eid] > 0)
168 assert(pos != std::numeric_limits<std::size_t>::max());
169 new_node_id = dup_newNodeIDs[pos];
175 vec_junction_nodeID_matIDs, node_id);
177 jct_matids, frac_matid);
179 auto const frac2_id =
181 assert(frac2_id != std::numeric_limits<std::size_t>::max());
182 auto prop_levelset2 =
184 "levelset" + std::to_string(frac2_id + 1));
187 if ((*prop_levelset2)[eid] <= 0)
192 assert(pos != std::numeric_limits<std::size_t>::max());
193 new_node_id = dup_newNodeIDs[pos];
195 else if ((*prop_levelset2)[eid] > 0)
198 new_node_id = dup_newNodeIDs.back();
203 e->
setNode(i, new_nodes[new_node_id]);
210 new_nodes, new_eles);
266 "Mesh property '{:s}' of unhandled data type '{:s}'. Please "
267 "check the data type of the mesh properties. The available "
275 "\n\t unsigned long,"
276 "\n\t unsigned long long,"
278 property->getPropertyName(),
279 typeid(*property).name());
283 vec_junction_nodeID_matIDs.size());
286 template <
typename T>
291 auto const n_src_comp =
property.getNumberOfGlobalComponents();
294 auto const n_dest_comp = (n_src_comp == 2) ? 3 : n_src_comp;
296 auto new_property = MeshLib::getOrCreateMeshProperty<T>(
301 assert(new_property->size() ==
306 assert(new_property->size() ==
312 "Property '{:s}' cannot be created because its mesh item type "
313 "'{:s}' is not supported.",
316 new_property->getPropertyName());
322 template <
typename T>
327 if (destination_property ==
nullptr)
337 auto const n_dest_comp =
342 auto last = std::copy_n(&source_property[i * n_src_comp],
344 &(*destination_property)[i * n_dest_comp]);
346 std::fill_n(last, n_dest_comp - n_src_comp, T{0});
351 for (
unsigned k = 0; k < itr.second.size(); k++)
354 &(*destination_property)[itr.first * n_dest_comp],
356 &(*destination_property)[itr.second[k] * n_dest_comp]);
362 assert(source_property.
size() == destination_property->
size());
363 std::copy(source_property.begin(), source_property.end(),
364 destination_property->begin());
369 "Property '{:s}' values cannot be copied because its mesh item "
370 "type '{:s}' is not supported. Unexpected error, because the "
371 "destination property was created.",
377 unsigned const n_junctions)
379 auto const& u = *
_output_mesh->getProperties().getPropertyVector<
double>(
381 auto const n_u_comp = u.getNumberOfGlobalComponents();
382 assert(u.size() ==
_output_mesh->getNodes().size() * 3);
384 *
_output_mesh->getProperties().createNewPropertyVector<
double>(
386 total_u.resize(u.size());
387 std::copy(cbegin(u), cend(u), begin(total_u));
389 for (
unsigned enrich_id = 0; enrich_id < n_fractures + n_junctions;
393 std::vector<double> nodal_levelset(
395 std::numeric_limits<double>::quiet_NaN());
397 auto const& ele_levelset =
398 *
_output_mesh->getProperties().getPropertyVector<
double>(
399 "levelset" + std::to_string(enrich_id + 1));
406 const double e_levelset = ele_levelset[e->getID()];
408 for (
unsigned i = 0; i < e->getNumberOfNodes(); i++)
416 *
_output_mesh->getProperties().getPropertyVector<
double>(
417 "displacement_jump" + std::to_string(enrich_id + 1));
418 for (
unsigned i = 0; i <
_output_mesh->getNodes().size(); i++)
420 for (
int j = 0; j < n_u_comp; j++)
422 total_u[i * n_u_comp + j] +=
423 nodal_levelset[i] * g[i * n_u_comp + j];
Definition of Duplicate functions.
Definition of the Element class.
void WARN(char const *fmt, Args const &... args)
Definition of the Node class.
virtual unsigned getNumberOfNodes() const =0
virtual void setNode(unsigned idx, Node *node)=0
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
const std::string getName() const
Get name of the mesh.
Properties & getProperties()
std::size_t getNumberOfNodes() const
Get the number of nodes.
const Node * getNode(std::size_t idx) const
Get the node with the given index.
bool hasPropertyVector(std::string const &name) const
PropertyVector< T > const * getPropertyVector(std::string const &name) const
std::string const & getPropertyName() const
MeshItemType getMeshItemType() const
int getNumberOfGlobalComponents() const
void copyPropertyValues(MeshLib::PropertyVector< T > const &source_property, MeshLib::PropertyVector< T > *const destination_property)
MeshLib::Mesh const & _org_mesh
PostProcessTool(MeshLib::Mesh const &org_mesh, std::vector< int > const &vec_fracture_mat_IDs, std::vector< std::vector< MeshLib::Node * >> const &vec_vec_fracture_nodes, std::vector< std::vector< MeshLib::Element * >> const &vec_vec_fracture_matrix_elements, std::vector< std::pair< std::size_t, std::vector< int >>> const &vec_branch_nodeID_matIDs, std::vector< std::pair< std::size_t, std::vector< int >>> const &vec_junction_nodeID_matIDs)
std::map< std::size_t, std::vector< std::size_t > > _map_dup_newNodeIDs
void calculateTotalDisplacement(unsigned const n_fractures, unsigned const n_junctions)
MeshLib::PropertyVector< T > * createProperty(MeshLib::PropertyVector< T > const &property)
std::unique_ptr< MeshLib::Mesh > _output_mesh
std::optional< typename Container::value_type > findFirstNotEqualElement(Container const &container, typename Container::value_type const &element)
std::size_t findIndex(Container const &container, typename Container::value_type const &element)
const char * toString(mgis::behaviour::Behaviour::Kinematic kin)
Converts MGIS kinematic to a string representation.
void copy(PETScVector const &x, PETScVector &y)
std::vector< Node * > copyNodeVector(const std::vector< Node * > &nodes)
Creates a deep copy of a Node vector.
std::size_t getNodeIndex(Element const &element, unsigned const idx)
std::vector< Element * > copyElementVector(std::vector< Element * > const &elements, std::vector< Node * > const &new_nodes, std::vector< std::size_t > const *const node_id_map)
bool includesNodeID(std::vector< MeshLib::Node * > const &vec_nodes, std::size_t node_id)
std::vector< int > const & getMaterialIdsForNode(std::vector< std::pair< std::size_t, std::vector< int >>> const &vec_nodeID_matIDs, std::size_t nodeID)