10#include <tclap/CmdLine.h>
12#include <unordered_map>
23template <
typename MeshElement>
27 constexpr int dim = MeshElement::dimension;
33 std::vector<std::array<double, 3>> coords;
34 coords.reserve(Ns.size());
36 for (
auto const& N : Ns)
46template <
typename Element>
49template <
typename ElementRule>
55std::unordered_map<MeshLib::CellType, std::vector<std::array<double, 3>> (*)(
61 std::vector<std::array<double, 3>> (*)(
64 map_cell_type_to_element_coords_interpolator;
66 map_cell_type_to_element_coords_interpolator.reserve(
67 boost::mp11::mp_size<NumLib::AllElementTraitsLagrange>::value);
69 boost::mp11::mp_for_each<NumLib::AllElementTraitsLagrange>(
70 [&map_cell_type_to_element_coords_interpolator]<
typename ETL>(ETL)
72 using MeshElement =
typename ETL::Element;
73 auto constexpr cell_type =
76 auto const [it, newly_inserted] =
77 map_cell_type_to_element_coords_interpolator.emplace(
83 "Coordinate interpolator for cell type {} is already "
89 return map_cell_type_to_element_coords_interpolator;
96 auto const map_cell_type_to_element_coords_interpolator =
99 std::vector<MeshLib::Node*> nodes;
103 auto const cell_type = element->getCellType();
106 map_cell_type_to_element_coords_interpolator.find(cell_type);
107 if (it == map_cell_type_to_element_coords_interpolator.end())
109 OGS_FATAL(
"Unsupported cell type {} for element #{}",
113 auto const& element_coords_interpolator = it->second;
114 auto const coords = element_coords_interpolator(*element, sm_cache);
116 for (
auto& cs : coords)
129 std::optional<unsigned> integration_order;
131 for (
auto const& [name, property] : properties)
133 if (property->getMeshItemType() !=
139 if (name ==
"IntegrationPointMetaData" || name ==
"OGS_VERSION")
148 if (!integration_order)
150 integration_order = order;
152 else if (integration_order != order)
154 OGS_FATAL(
"Integration orders differ: {} != {}", *integration_order,
159 if (!integration_order)
161 OGS_FATAL(
"Integration order could not be determined.");
164 return *integration_order;
169 std::size_t
const num_ips)
171 for (
auto const& [prop_name, prop_in] : props_in)
173 auto const mesh_item_type = prop_in->getMeshItemType();
180 auto const num_comp = prop_in->getNumberOfGlobalComponents();
181 auto const* prop_in_double =
184 if (prop_in_double ==
nullptr)
187 "Ignoring non-double-valued property '{}' with {} components "
189 prop_name, num_comp, toString(mesh_item_type));
193 DBUG(
"Converting property '{}' with {} components on {}", prop_name,
194 num_comp, toString(mesh_item_type));
199 "A property vector with name '{}' already exists. Not "
204 if (
auto const num_ips_actual = prop_in_double->getNumberOfTuples();
205 num_ips_actual != num_ips)
208 "Property vector '{}' has {} tuples, which differs from "
209 "the number of integration points ({}). Skipping this "
211 prop_name, num_ips_actual, num_ips);
217 static_cast<std::vector<double>&
>(*prop_out) = *prop_in_double;
237 "Creates a point cloud mesh for the integration point data existing on "
238 "a given input mesh.\n\n"
239 "OpenGeoSys-6 software, version " +
242 "Copyright (c) 2012-2024, OpenGeoSys Community "
243 "(http://www.opengeosys.org)",
245 TCLAP::ValueArg<std::string> arg_out_file(
246 "o",
"output-file",
"the output mesh (point cloud, VTU file)",
true,
"",
248 cmd.add(arg_out_file);
249 TCLAP::ValueArg<std::string> arg_in_file(
250 "i",
"input-file",
"the input mesh (VTU file)",
true,
"",
"path");
251 cmd.add(arg_in_file);
253 cmd.parse(argc, argv);
257 std::unique_ptr<MeshLib::Mesh const> mesh_in(
263 MeshLib::Mesh point_cloud(
"point_cloud", std::move(nodes), {});
266 point_cloud.getProperties(),
267 point_cloud.getNumberOfNodes());
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Properties & getProperties()
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
bool existsPropertyVector(std::string_view name) const
PropertyVector< T > * createNewPropertyVector(std::string_view name, MeshItemType mesh_item_type, std::size_t n_components=1)
boost::mp11::mp_at< ShapeFunctionsHigherOrder, boost::mp11::mp_find< MeshElements, MeshElement > > ShapeFunctionHigherOrder
auto const & NsHigherOrder() const
unsigned determineIntegrationOrder(MeshLib::Mesh const &mesh)
int main(int argc, char **argv)
std::vector< MeshLib::Node * > computePointCloudNodes(MeshLib::Mesh const &mesh, unsigned const integration_order)
std::unordered_map< MeshLib::CellType, std::vector< std::array< double, 3 > >(*)(MeshLib::Element const &, NumLib::ShapeMatrixCache const &)> createElementCoordInterpolatorsForAllElementTypes()
void copyDoubleValuedFieldDataToPointCloud(MeshLib::Properties const &props_in, MeshLib::Properties &props_out, std::size_t const num_ips)
std::vector< std::array< double, 3 > > interpolateElementCoords(MeshLib::Element const &e, NumLib::ShapeMatrixCache const &sm_cache)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, std::set< std::string > variable_output_names)
CellType
Types of mesh elements supported by OpenGeoSys.
IntegrationPointMetaData getIntegrationPointMetaData(MeshLib::Properties const &properties, std::string const &name)
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
std::array< double, 3 > interpolateCoordinates(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
Definition of readMeshFromFile function.