41 context.require(
action->getMeshRequirement());
64 std::string meshName =
mesh->getName();
75 const std::string &fromParticipant,
78 const bool allowDirectAccess)
80 std::string meshName =
mesh->getName();
88 context.mesh = std::move(
mesh);
89 context.receiveMeshFrom = fromParticipant;
90 context.safetyFactor = safetyFactor;
91 context.geoFilter = geoFilter;
92 context.allowDirectAccess = allowDirectAccess;
172 [data](
const auto &mckv) {
173 const auto &meshData = mckv.second->mesh->data();
174 return std::any_of(meshData.begin(), meshData.end(), [data](const auto &dptr) {
175 return dptr->getName() == data;
183 const auto match = std::find_if(meshData.begin(), meshData.end(), [data](
auto &dptr) { return dptr->getName() == data; });
184 return match != meshData.end();
233 return getMesh(variant).getName() == mesh;
240 [
mesh](
const auto &ctx) { return ctx.mesh->getName() == mesh; });
246 [
mesh](
const auto &ctx) { return ctx.mesh->getName() == mesh; });
252 [
mesh](
const auto &ctx) { return ctx.mesh->getName() == mesh; });
254 return it->allowDirectAccess;
262 [
mesh](
const auto &ctx) { return ctx.mesh->getName() == mesh; });
270 [
mesh](
const auto &ctx) { return ctx.mesh->getName() == mesh; });
278 [
mesh](
const auto &ctx) { return ctx.mesh->getName() == mesh; });
286 [
mesh](
const auto &ctx) { return ctx.mesh->getName() == mesh; });
377 if (context.everyNTimeWindows < 1) {
381 PRECICE_DEBUG(
"Exporting initial mesh {} to location \"{}\"", context.meshName, context.location);
382 context.exporter->doExport(0, 0.0);
384 if (context.updateSeries) {
385 PRECICE_DEBUG(
"Exporting series file of mesh {} to location \"{}\"", context.meshName, context.location);
386 context.exporter->exportSeries();
391 watchPoint->exportPointData(0.0);
395 watchIntegral->exportIntegralData(0.0);
407 if (context.everyIteration) {
408 PRECICE_DEBUG(
"Exporting mesh {} for iteration {} to location \"{}\"", context.meshName, exp.
iteration, context.location);
413 PRECICE_DEBUG(
"Exporting mesh {} for timewindow {} to location \"{}\"", context.meshName, exp.
timewindow, context.location);
418 PRECICE_DEBUG(
"Exporting series file of mesh {} to location \"{}\"", context.meshName, context.location);
419 context.exporter->exportSeries();
426 watchPoint->exportPointData(exp.
time);
430 watchIntegral->exportIntegralData(exp.
time);
440 "Mesh \"{} cannot be used twice by participant {}. "
441 "Please remove one of the provide/receive-mesh nodes with name=\"{}\"./>",
448 "ParticipantState \"{}\" can read/write data \"{}\" from/to mesh \"{}\" only once. "
449 "Please remove any duplicate instances of write-data/read-data nodes.",
459 return " This participant only knows mesh \"" +
_meshContexts.begin()->first +
"\".";
463 if (matches.front().distance < 3) {
464 return " Did you mean mesh \"" + matches.front().name +
"\"?";
466 return fmt::format(
" Available meshes are: {}", fmt::join(
_meshContexts | boost::adaptors::map_keys,
", "));
477 std::vector<std::string> otherMeshes;
479 if (mc->mesh->hasDataName(data)) {
480 return " Did you mean the data of mesh \"" + mc->mesh->getName() +
"\"?";
487 if (localData.size() == 1) {
488 return " This mesh only knows data \"" + localData.front() +
"\".";
493 if (matches.front().distance < 3) {
494 return " Did you mean data \"" + matches.front().name +
"\"?";
497 return fmt::format(
" Available data are: {}", fmt::join(localData,
", "));
502 if (mappingType ==
"write") {
504 context.initializeMappingDataCache();
508 context.initializeMappingDataCache();
516 meshContext(fromMesh).fromMappingContexts.push_back(mappingContext);
521 meshContext(toMesh).toMappingContexts.push_back(mappingContext);
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
bool isMeshReceived(std::string_view mesh) const
Is a mesh with this name received by this participant?
ProvidedMeshContext & providedMeshContext(std::string_view mesh)
std::string hintForMeshData(std::string_view mesh, std::string_view data) const
bool isDataUsed(std::string_view mesh, std::string_view data) const
Is the data used by this participant?
bool isMeshUsed(std::string_view mesh) const
Is a mesh with this name used by this participant?
std::vector< io::ExportContext > _exportContexts
Export contexts to export meshes, data, and more.
MeshMap< MeshContext * > _meshContexts
All mesh contexts involved in a simulation (for name-based lookup)
bool isDataWrite(std::string_view mesh, std::string_view data) const
Is the participant allowed to write the data?
const ReadDataContext & readDataContext(std::string_view mesh, std::string_view data) const
DataMap< ReadDataContext > _readDataContexts
void addAction(action::PtrAction &&action)
Adds a configured Action to the participant.
bool isDataRead(std::string_view mesh, std::string_view data) const
Is the participant allowed to read the data?
std::string hintForMesh(std::string_view mesh) const
std::vector< PtrWatchPoint > & watchPoints()
Provided access to all WatchPoints.
const MeshContext & meshContext(std::string_view mesh) const
Mesh queries.
void checkDuplicatedData(std::string_view mesh, std::string_view data)
void addWatchPoint(const PtrWatchPoint &watchPoint)
Adds a configured WatchPoint to the ParticipantState.
std::vector< MappingContext > _readMappingContexts
Read mapping contexts used by the participant.
void addWriteMappingContext(const MappingContext &mappingContext)
Adds a configured write Mapping to the ParticipantState.
std::deque< ProvidedMeshContext > & providedMeshContexts()
ParticipantState(std::string name, mesh::PtrMeshConfiguration &meshConfig)
Constructor.
std::vector< action::PtrAction > _actions
std::vector< MeshContextVariant > _usedMeshContexts
Mesh contexts used by the participant.
bool hasExports() const
Returns true, if the participant has any exports enabled.
std::vector< action::PtrAction > & actions()
Provided access to all Action.
std::vector< PtrWatchIntegral > _watchIntegrals
bool hasWriteMappings() const
Returns true, if the participant has at least one write mapping.
void setUsePrimaryRank(bool useIntraComm)
Sets weather the participant was configured with a primary tag.
void exportIntermediate(IntermediateExport exp)
Exports timewindows and iterations of meshes and watchpoints.
ReceivedMeshContext & receivedMeshContext(std::string_view mesh)
std::deque< ProvidedMeshContext > _providedMeshContexts
Provided mesh contexts (owning container)
void provideMesh(mesh::PtrMesh mesh)
Adds a mesh to be provided by the participant.
mesh::PtrMesh findMesh(std::string_view data) const
Returns the mesh associated with ReadDataContext with given data name in _readDataContexts of this Pa...
void addReadMappingContext(const MappingContext &mappingContext)
Adds a configured read Mapping to the ParticipantState.
bool hasMesh(std::string_view mesh) const
Does preCICE know a mesh with this name?
DataMap< WriteDataContext > _writeDataContexts
void addWatchIntegral(const PtrWatchIntegral &watchIntegral)
Adds a configured WatchIntegral to the ParticipantState.
std::vector< MappingContext > _writeMappingContexts
Write mapping contexts used by the participant.
void receiveMesh(mesh::PtrMesh mesh, const std::string &fromParticipant, double safetyFactor, partition::ReceivedPartition::GeometricFilter geoFilter, const bool allowDirectAccess)
Adds a mesh to be received by the participant.
const std::vector< MeshContextVariant > & usedMeshContexts() const
bool hasData(std::string_view mesh, std::string_view data) const
Is the dataID know to preCICE?
void configureOutputMeshContext(std::string_view toMesh, impl::MappingContext &mappingContext, mapping::Mapping::MeshRequirement requirement)
Configures the mesh context with connectivity requirements and adds it to the mappingcontext.
void addWriteData(const mesh::PtrData &data, const mesh::PtrMesh &mesh)
void addReadData(const mesh::PtrData &data, const mesh::PtrMesh &mesh)
Adds a configured read Data to the ParticipantState.
const std::string & getName() const
std::deque< ReceivedMeshContext > _receivedMeshContexts
Received mesh contexts (owning container)
std::vector< PtrWatchPoint > _watchPoints
bool isDirectAccessAllowed(std::string_view mesh) const
void addExportContext(const io::ExportContext &context)
Adds a configured ExportContext to export meshes and data.
std::deque< ReceivedMeshContext > & receivedMeshContexts()
bool useIntraComm() const
Returns true, if the participant uses a primary tag.
bool isMeshProvided(std::string_view mesh) const
Is a mesh with this name provided by this participant?
void configureInputMeshContext(std::string_view fromMesh, impl::MappingContext &mappingContext, mapping::Mapping::MeshRequirement requirement)
Configures the mesh context with connectivity requirements and adds it to the mappingcontext.
std::vector< MappingContext > & writeMappingContexts()
Provided access to all write MappingContext.
const std::vector< io::ExportContext > & exportContexts() const
Returns all ExportContext for exporting meshes and data.
bool hasReadMappings() const
Returns true, if the participant has at least one read mapping.
std::vector< MappingContext > & readMappingContexts()
Provided access to all read MappingContext.
const WriteDataContext & writeDataContext(std::string_view mesh, std::string_view data) const
void initializeMappingDataCache(std::string_view mappingType)
Initializes the MappingDataCache in the DataContext after having computed the mappings.
void checkDuplicatedUse(std::string_view mesh)
std::vector< PtrWatchIntegral > & watchIntegrals()
Provided access to all WatchIntegrals.
Stores one Data object with related mesh. Context stores data to be read from and potentially provide...
Stores one Data object with related mesh. Context stores data to be written to and potentially provid...
MeshRequirement
Specifies requirements for the input and output meshes of a mapping.
GeometricFilter
Defines the type of geometric filter used.
contains actions to modify exchanged data.
std::unique_ptr< Action > PtrAction
std::shared_ptr< WatchPoint > PtrWatchPoint
std::variant< ProvidedMeshContext *, ReceivedMeshContext * > MeshContextVariant
Type alias for variant holding either provided or received mesh context pointers.
std::shared_ptr< WatchIntegral > PtrWatchIntegral
provides Mesh, Data and primitives.
std::shared_ptr< Data > PtrData
std::shared_ptr< Mesh > PtrMesh
std::shared_ptr< MeshConfiguration > PtrMeshConfiguration
std::vector< StringMatch > computeMatches(std::string_view given, const Container &expected)
Holds a data mapping and related information.
Type that represent a compound key of two values.
Context for a mesh provided by this participant.
Context for a mesh received from another participant.