10#include <tclap/CmdLine.h>
12#include <unordered_map>
22template <
typename MeshElement>
26 constexpr int dim = MeshElement::dimension;
32 std::vector<std::array<double, 3>> coords;
33 coords.reserve(Ns.size());
35 for (
auto const& N : Ns)
45template <
typename Element>
48template <
typename ElementRule>
54std::unordered_map<MeshLib::CellType, std::vector<std::array<double, 3>> (*)(
60 std::vector<std::array<double, 3>> (*)(
63 map_cell_type_to_element_coords_interpolator;
65 map_cell_type_to_element_coords_interpolator.reserve(
66 boost::mp11::mp_size<NumLib::AllElementTraitsLagrange>::value);
68 boost::mp11::mp_for_each<NumLib::AllElementTraitsLagrange>(
69 [&map_cell_type_to_element_coords_interpolator]<
typename ETL>(ETL)
71 using MeshElement =
typename ETL::Element;
72 auto constexpr cell_type =
75 auto const [it, newly_inserted] =
76 map_cell_type_to_element_coords_interpolator.emplace(
82 "Coordinate interpolator for cell type {} is already "
88 return map_cell_type_to_element_coords_interpolator;
95 auto const map_cell_type_to_element_coords_interpolator =
98 std::vector<MeshLib::Node*> nodes;
102 auto const cell_type = element->getCellType();
105 map_cell_type_to_element_coords_interpolator.find(cell_type);
106 if (it == map_cell_type_to_element_coords_interpolator.end())
108 OGS_FATAL(
"Unsupported cell type {} for element #{}",
112 auto const& element_coords_interpolator = it->second;
113 auto const coords = element_coords_interpolator(*element, sm_cache);
115 for (
auto& cs : coords)
128 std::optional<unsigned> integration_order;
130 for (
auto const& [name, property] : properties)
132 if (property->getMeshItemType() !=
138 if (name ==
"IntegrationPointMetaData" || name ==
"OGS_VERSION")
147 if (!integration_order)
149 integration_order = order;
151 else if (integration_order != order)
153 OGS_FATAL(
"Integration orders differ: {} != {}", *integration_order,
158 if (!integration_order)
160 OGS_FATAL(
"Integration order could not be determined.");
163 return *integration_order;
168 std::size_t
const num_ips)
170 for (
auto const& [prop_name, prop_in] : props_in)
172 auto const mesh_item_type = prop_in->getMeshItemType();
179 auto const num_comp = prop_in->getNumberOfGlobalComponents();
180 auto const* prop_in_double =
183 if (prop_in_double ==
nullptr)
186 "Ignoring non-double-valued property '{}' with {} components "
188 prop_name, num_comp, toString(mesh_item_type));
192 DBUG(
"Converting property '{}' with {} components on {}", prop_name,
193 num_comp, toString(mesh_item_type));
198 "A property vector with name '{}' already exists. Not "
203 if (
auto const num_ips_actual = prop_in_double->getNumberOfTuples();
204 num_ips_actual != num_ips)
207 "Property vector '{}' has {} tuples, which differs from "
208 "the number of integration points ({}). Skipping this "
210 prop_name, num_ips_actual, num_ips);
216 static_cast<std::vector<double>&
>(*prop_out) = *prop_in_double;
236 "Creates a point cloud mesh for the integration point data existing on "
237 "a given input mesh.\n\n"
238 "OpenGeoSys-6 software, version " +
241 "Copyright (c) 2012-2024, OpenGeoSys Community "
242 "(http://www.opengeosys.org)",
244 TCLAP::ValueArg<std::string> arg_out_file(
245 "o",
"output-file",
"the output mesh (point cloud, VTU file)",
true,
"",
247 cmd.add(arg_out_file);
248 TCLAP::ValueArg<std::string> arg_in_file(
249 "i",
"input-file",
"the input mesh (VTU file)",
true,
"",
"path");
250 cmd.add(arg_in_file);
252 cmd.parse(argc, argv);
254 std::unique_ptr<MeshLib::Mesh const> mesh_in(
260 MeshLib::Mesh point_cloud(
"point_cloud", std::move(nodes), {});
263 point_cloud.getProperties(),
264 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.