<aside> 💡 Allows to read a mesh as a mesh region or as a meshes container. Implement either the “mesh_provider” operator or the “meshes_provider” operator. The “meshes_provider” operator allows to describe varying mesh (for example: time varying mesh)

</aside>

Mesh Provider

Untitled

Document it

The specification allows to document each operator. For consistency, the specification can be used through different reader plugins.

struct CustomMeshProvider
	{
		// TO DO: rename "custom_solver" to the real solver name and "custom_extension" to the real file extension
		static std::string name() { return "custom_solver::custom_extension::mesh_provider"; }

		static void run(ansys::dpf::OperatorMain& main);

		static ansys::dpf::OperatorSpecification specification()
		{
			ansys::dpf::OperatorSpecification spec;
			spec.setDocumentation("Read a mesh from result streams.");
			spec.setInputPins(
				{
					ansys::dpf::PinDefinition(ansys::dpf::eStreamPin)
						.setName("streams_container")
						.setAcceptedTypes({ ansys::dpf::types::streams })
						.setDoc("result file container allowed to be kept open to cache data")
						.setOptional(true),
					ansys::dpf::PinDefinition(ansys::dpf::eDataSourcesPin)
						.setName("data_sources")
						.setAcceptedTypes({ ansys::dpf::types::data_sources })
						.setDoc("result file path container, used if no streams are set"),
					
					//Optionally
					//for adaptive meshes
					ansys::dpf::PinDefinition(ansys::dpf::eTimeScopPin)
						.setName("time_scoping")
						.setAcceptedTypes({ ansys::dpf::types::integer })
						.setDoc("time/freq set id required in output")
						.setOptional(true),
				});

			spec.setOutputPins(
				{
					ansys::dpf::PinDefinition(0).setName("mesh")
						.setAcceptedTypes({ ansys::dpf::types::meshed_region })
						.setDoc("meshed region"),
				});

			spec.setProperty(ansys::dpf::spec::exposure::sExposure, ansys::dpf::spec::exposure::sPrivate);

			return spec;
		}
	};

Implementation

For the "run" method implementation, refer to here:

For a template enabling to fill a MeshedRegion from a Stream, refer to:

The Mesh or as called in DPF the MeshedRegion has a very simple API allowing to build a mesh from scratch with these 3 methods:

ansys::dpf::MeshedRegion mesh;
mesh.prepareConstruction(num_nodes, num_elements);
mesh.addNode(node_id, coordinates);
mesh.addElement(element_type, element_id, nodes_indexes_connectivity);

Meshes Provider

Untitled

Document it

The specification allows to document each operator. For consistency, the specification can be used through different reader plugins.

struct CustomMeshesProvider
	{
		// TO DO: rename "custom_solver" to the real solver name and "custom_extension" to the real file extension
		static std::string name() { return "custom_solver::custom_extension::meshes_provider"; }

		static void run(ansys::dpf::OperatorMain& main);

		static ansys::dpf::OperatorSpecification specification()
		{
			ansys::dpf::OperatorSpecification spec;
			spec.setDocumentation("Read meshes from result streams. Meshes can be spatially or temporally varying.");
			spec.setInputPins(
				{
					ansys::dpf::PinDefinition(ansys::dpf::eStreamPin)
						.setName("streams_container")
						.setAcceptedTypes({ ansys::dpf::types::streams })
						.setDoc("result file container allowed to be kept open to cache data")
						.setOptional(true),
					ansys::dpf::PinDefinition(ansys::dpf::eDataSourcesPin)
						.setName("data_sources")
						.setAcceptedTypes({ ansys::dpf::types::data_sources })
						.setDoc("result file path container, used if no streams are set"),

					//Optionally
					//for adaptive meshes
					ansys::dpf::PinDefinition(ansys::dpf::eTimeScopPin)
						.setName("time_scoping")
						.setAcceptedTypes({ ansys::dpf::types::intVector, ansys::dpf::types::scoping })
						.setDoc("time/freq set ids required in output")
						.setOptional(true),
				});

			spec.setOutputPins(
				{
					ansys::dpf::PinDefinition(0).setName("meshes").setAcceptedTypes({ ansys::dpf::types::meshes_container }).setDoc("meshes container"),
				});

			spec.setProperty(ansys::dpf::spec::exposure::sExposure, ansys::dpf::spec::exposure::sPrivate);

			return spec;
		}
	};