31 auto& ogs_version_field = *MeshLib::getOrCreateMeshProperty<char>(
41 std::vector<GlobalVector*>
const& x,
42 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& dof_table,
44 std::string
const& output_name,
47 DBUG(
" secondary variable {:s}", output_name);
49 auto& nodal_values_mesh = *MeshLib::getOrCreateMeshProperty<double>(
52 if (nodal_values_mesh.size() !=
56 "Nodal property `{:s}' does not have the right number of "
57 "components. Expected: {:d}, actual: {:d}",
60 nodal_values_mesh.size());
63 std::unique_ptr<GlobalVector> result_cache;
64 auto const& nodal_values =
67 std::size_t
const global_vector_size =
68 nodal_values.getLocalSize() + nodal_values.getGhostSize();
70 std::size_t
const global_vector_size = nodal_values.size();
72 if (nodal_values_mesh.size() != global_vector_size)
75 "Secondary variable `{:s}' did not evaluate to the right number of "
76 "components. Expected: {:d}, actual: {:d}.",
77 var.
name, nodal_values_mesh.size(), global_vector_size);
81 nodal_values.copyValues(nodal_values_mesh);
86 std::vector<GlobalVector*>
const& x,
87 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& dof_table,
89 std::string
const& output_name,
97 DBUG(
" secondary variable {:s} residual", output_name);
98 auto const& property_name_res = output_name +
"_residual";
100 auto& residuals_mesh = *MeshLib::getOrCreateMeshProperty<double>(
103 if (residuals_mesh.size() !=
107 "Cell property `{:s}' does not have the right number of "
108 "components. Expected: {:d}, actual: {:d}",
111 residuals_mesh.size());
114 std::unique_ptr<GlobalVector> result_cache;
115 auto const& residuals =
118 std::size_t
const global_vector_size =
119 residuals.getLocalSize() + residuals.getGhostSize();
121 std::size_t
const global_vector_size = residuals.size();
123 if (residuals_mesh.size() != global_vector_size)
126 "The residual of secondary variable `{:s}' did not evaluate to the "
127 "right number of components. Expected: {:d}, actual: {:d}.",
128 var.
name, residuals_mesh.size(), global_vector_size);
132 residuals.copyValues(residuals_mesh);
138 const double t, std::vector<GlobalVector*>
const& x,
int const process_id,
140 [[maybe_unused]] std::vector<NumLib::LocalToGlobalIndexMap const*>
const&
142 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& dof_table,
143 std::vector<std::reference_wrapper<ProcessVariable>>
const&
146 bool const output_secondary_variable,
147 std::vector<std::unique_ptr<IntegrationPointWriter>>
const*
const
148 integration_point_writer,
151 DBUG(
"Process output data.");
160 std::vector<double> x_copy(x[process_id]->getLocalSize() +
161 x[process_id]->getGhostSize());
163 std::vector<double> x_copy(x[process_id]->size());
165 x[process_id]->copyValues(x_copy);
168 std::set<std::string> already_output;
170 int global_component_offset = 0;
171 int global_component_offset_next = 0;
173 const auto number_of_dof_variables =
174 dof_table[process_id]->getNumberOfVariables();
176 for (
int variable_id = 0;
177 variable_id < static_cast<int>(process_variables.size());
184 const int sub_meshset_id =
185 (number_of_dof_variables == 1) ? 0 : variable_id;
187 if (number_of_dof_variables > 1)
189 global_component_offset = global_component_offset_next;
190 global_component_offset_next += n_components;
193 if (output_variables.find(pv.
getName()) == output_variables.cend())
198 already_output.insert(pv.
getName());
203 auto& output_data = *MeshLib::getOrCreateMeshProperty<double>(
206 for (
int component_id = 0; component_id < num_comp; ++component_id)
208 auto const& mesh_subset = dof_table[process_id]->getMeshSubset(
209 sub_meshset_id, component_id);
210 auto const mesh_id = mesh_subset.getMeshID();
211 for (
auto const* node : mesh_subset.getNodes())
214 if (bulk_dof_tables[process_id] != dof_table[process_id])
220 "The required bulk node ids map does not exist in "
221 "the boundary mesh '{:s}' or has the wrong data "
222 "type (should be equivalent to C++ data type "
223 "std::size_t which is an unsigned integer of size "
224 "{:d} or UInt64 in vtk terminology).",
225 mesh.
getName(),
sizeof(std::size_t));
227 auto const bulk_node_id_map =
234 auto const bulk_node_id =
235 bulk_node_id_map[node->getID()];
237 std::size_t
const bulk_mesh_id = 0;
241 auto const global_component_id =
242 global_component_offset + component_id;
244 bulk_dof_tables[process_id]->getLocalIndex(
245 l, global_component_id,
246 x[process_id]->getRangeBegin(),
247 x[process_id]->getRangeEnd());
249 output_data[node->getID() * n_components +
250 component_id] = x_copy[index];
258 auto const global_component_id =
259 global_component_offset + component_id;
260 auto const index = dof_table[process_id]->getLocalIndex(
261 l, global_component_id, x[process_id]->getRangeBegin(),
262 x[process_id]->getRangeEnd());
264 output_data[node->getID() * n_components + component_id] =
270 if (output_secondary_variable)
272 for (
auto const& external_variable_name : secondary_variables)
274 auto const&
name = external_variable_name.first;
275 if (!already_output.insert(
name).second)
282 t, x, dof_table, secondary_variables.get(
name),
name, mesh);
287 t, x, dof_table, secondary_variables.get(
name),
name, mesh);
292 if (integration_point_writer !=
nullptr)
299 bool const compress_output,
int const data_mode)
302 DBUG(
"Writing output to '{:s}'.", file_name);
312 fesetenv(FE_DFL_ENV);
void DBUG(char const *fmt, Args const &... args)
Definition of mesh class for partitioned mesh (by node) for parallel computing within the framework o...
static void addSecondaryVariableNodes(double const t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, ProcessLib::SecondaryVariable const &var, std::string const &output_name, MeshLib::Mesh &mesh)
static void addSecondaryVariableResiduals(double const t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, ProcessLib::SecondaryVariable const &var, std::string const &output_name, MeshLib::Mesh &mesh)
static void addOgsVersion(MeshLib::Mesh &mesh)
Implementation of the VtuInterface class.
Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures....
bool writeToFile(std::filesystem::path const &file_path)
const std::string getName() const
Get name of the mesh.
Properties & getProperties()
std::size_t getNumberOfNodes() const
Get the number of nodes.
std::size_t getNumberOfElements() const
Get the number of elements.
bool isGhostNode(const std::size_t node_id) const
Check whether a node with ID of node_id is a ghost node.
PropertyVector< T > const * getPropertyVector(std::string const &name) const
bool existsPropertyVector(std::string const &name) const
std::string const & getName() const
int getNumberOfGlobalComponents() const
Returns the number of components of the process variable.
Handles configuration of several secondary variables from the project file.
const std::string OGS_VERSION
GITINFOLIB_EXPORT const std::string ogs_version
void addProcessDataToMesh(const double t, std::vector< GlobalVector * > const &x, int const process_id, MeshLib::Mesh &mesh, [[maybe_unused]] std::vector< NumLib::LocalToGlobalIndexMap const * > const &bulk_dof_tables, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< std::reference_wrapper< ProcessVariable >> const &process_variables, SecondaryVariableCollection const &secondary_variables, bool const output_secondary_variable, std::vector< std::unique_ptr< IntegrationPointWriter >> const *const integration_point_writer, OutputDataSpecification const &process_output)
void addIntegrationPointWriter(MeshLib::Mesh &mesh, std::vector< std::unique_ptr< IntegrationPointWriter >> const &integration_point_writer)
void makeOutput(std::string const &file_name, MeshLib::Mesh const &mesh, bool const compress_output, int const data_mode)
Holds information about which variables to write to output files.
bool const output_residuals
Tells if also to output extrapolation residuals.
std::set< std::string > output_variables
All variables that shall be output.
Function const eval_field
Computes the value of the field at every node of the underlying mesh.
const unsigned num_components
Number of components of the variable.
Function const eval_residuals
Stores information about a specific secondary variable.
SecondaryVariableFunctions fcts
Functions used for computing the secondary variable.
std::string const name
Name of the variable; used, e.g., for output.