Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bindings compatible with preCICE v3 #47

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions +precice/@Participant/Participant.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,6 @@ function finalize(obj)
bool = preciceGateway(uint8(27));
end

%% Mesh Access
% hasMesh
function bool = hasMesh(obj,meshName)
if ischar(meshName)
meshName = string(meshName);
end
bool = preciceGateway(uint8(40),meshName);
end

% hasData
function bool = hasData(obj,meshName,dataName)
if ischar(meshName)
meshName = string(meshName);
end
if ischar(dataName)
dataName = string(dataName);
end
bool = preciceGateway(uint8(41),meshName,dataName);
end

% requiresMeshConnectivityFor
function bool = requiresMeshConnectivityFor(obj,meshName)
if ischar(meshName)
Expand Down Expand Up @@ -310,8 +290,8 @@ function setMeshAccessRegion(meshName, boundingBox)
preciceGateway(uint8(64),meshName,boundingBox);
end

% getMeshVerticesAndIDs
function [vertices, outIDs] = getMeshVerticesAndIDs(meshName)
% getMeshVertexIDsAndCoordinates
function [vertices, outIDs] = getMeshVertexIDsAndCoordinates(meshName)
if ischar(meshName)
meshName = string(meshName);
end
Expand Down
23 changes: 3 additions & 20 deletions +precice/@Participant/private/preciceGateway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ enum class FunctionID {
requiresReadingCheckpoint = 26,
requiresWritingCheckpoint = 27,

hasMesh = 40,
hasData = 41,
requiresMeshConnectivityFor = 42,
setMeshVertex = 43,
setMeshVertices = 44,
Expand All @@ -47,7 +45,7 @@ enum class FunctionID {
requiresGradientDataFor = 62,
writeGradientData = 63,
setMeshAccessRegion = 64,
getMeshVerticesAndIDs = 65,
getMeshVertexIDsAndCoordinates = 65,
};


Expand Down Expand Up @@ -189,21 +187,6 @@ class MexFunction: public matlab::mex::Function {
outputs[0] = factory.createArray<bool>({1,1}, {result});
break;
}
case FunctionID::hasMesh:
{
const std::string meshName = convertToString(inputs[1]);
bool output = interface->hasMesh(meshName);
outputs[0] = factory.createScalar<bool>(output);
break;
}
case FunctionID::hasData:
{
const std::string meshName = convertToString(inputs[1]);
const std::string dataName = convertToString(inputs[2]);
bool output = interface->hasData(meshName,dataName);
outputs[0] = factory.createScalar<bool>(output);
break;
}
case FunctionID::requiresMeshConnectivityFor:
{
const std::string meshName = convertToString(inputs[1]);
Expand Down Expand Up @@ -348,13 +331,13 @@ class MexFunction: public matlab::mex::Function {
interface->setMeshAccessRegion(meshName,boundingBox);
break;
}
case FunctionID::getMeshVerticesAndIDs:
case FunctionID::getMeshVertexIDsAndCoordinates:
{
const std::string meshName = convertToString(inputs[1]);
const TypedArray<int32_t> size = inputs[2];
std::vector <int32_t> ids(size[0]);
std::vector <double> positions(size[0]*3);
interface->getMeshVerticesAndIDs(meshName,ids,positions);
interface->getMeshVertexIDsAndCoordinates(meshName,ids,positions);
outputs[0] = factory.createArray<int32_t>({size[0]}, ids.data(), ids.data()+ids.size());
outputs[1] = factory.createArray<double>({size[0], 3}, positions.data(), positions.data()+positions.size());
break;
Expand Down
24 changes: 2 additions & 22 deletions +precice/@ParticipantOOP/ParticipantOOP.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,6 @@ function finalize(obj)
bool = feval(obj.oMexHost,"preciceGateway",uint8(26));
end

%% Mesh Access
% hasMesh
function bool = hasMesh(obj,meshName)
if ischar(meshName)
meshName = string(meshName);
end
bool = feval(obj.oMexHost,"preciceGateway",uint8(40),meshName);
end

% hasData
function bool = hasData(obj,meshName,dataName)
if ischar(meshName)
meshName = string(meshName);
end
if ischar(dataName)
dataName = string(dataName);
end
bool = feval(obj.oMexHost,"preciceGateway",uint8(41),meshName,dataName);
end

% requiresMeshConnectivityFor
function bool = requiresMeshConnectivityFor(obj,meshName)
if ischar(meshName)
Expand Down Expand Up @@ -312,8 +292,8 @@ function setMeshAccessRegion(meshName, boundingBox)
feval(obj.oMexHost,"preciceGateway",uint8(64),meshName,boundingBox);
end

% getMeshVerticesAndIDs
function [vertices, outIDs] = getMeshVerticesAndIDs(meshName)
% getMeshVertexIDsAndCoordinates
function [vertices, outIDs] = getMeshVertexIDsAndCoordinates(meshName)
if ischar(meshName)
meshName = string(meshName);
end
Expand Down
10 changes: 4 additions & 6 deletions tutorial/explicit/precice-config.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0"?>

<precice-configuration dimensions="2">
<precice-configuration>

<data:scalar name="I" />
<data:scalar name="U" />

<mesh name="MeshI">
<mesh name="MeshI" dimensions="2">
<use-data name="I" />
<use-data name="U" />
</mesh>

<mesh name="MeshU">
<mesh name="MeshU" dimensions="2">
<use-data name="U" />
<use-data name="I" />
</mesh>
Expand All @@ -37,7 +37,7 @@
direction="read" from="MeshI" to="MeshU" constraint="consistent"/>
</participant>

<m2n:sockets from="ParticipantI" to="ParticipantU"/>
<m2n:sockets acceptor="ParticipantI" connector="ParticipantU"/>

<coupling-scheme:serial-explicit>
<participants first="ParticipantI" second="ParticipantU" />
Expand All @@ -46,6 +46,4 @@
<exchange data="I" mesh="MeshI" from="ParticipantI" to="ParticipantU"/>
<exchange data="U" mesh="MeshU" from="ParticipantU" to="ParticipantI"/>
</coupling-scheme:serial-explicit>

</precice-configuration>

10 changes: 4 additions & 6 deletions tutorial/implicit/precice-config.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0"?>

<precice-configuration dimensions="2">
<precice-configuration>

<data:scalar name="I" />
<data:scalar name="U" />

<mesh name="MeshI">
<mesh name="MeshI" dimensions="2">
<use-data name="I" />
<use-data name="U" />
</mesh>

<mesh name="MeshU">
<mesh name="MeshU" dimensions="2">
<use-data name="U" />
<use-data name="I" />
</mesh>
Expand All @@ -37,16 +37,14 @@
direction="read" from="MeshI" to="MeshU" constraint="consistent"/>
</participant>

<m2n:sockets from="ParticipantI" to="ParticipantU"/>
<m2n:sockets acceptor="ParticipantI" connector="ParticipantU"/>

<coupling-scheme:serial-implicit>
<participants first="ParticipantI" second="ParticipantU" />
<max-time-windows value="1000" />
<time-window-size value="0.01" />
<max-iterations value="3" />
<min-iteration-convergence-measure min-iterations="5" data="I" mesh="MeshI"/>
<exchange data="I" mesh="MeshI" from="ParticipantI" to="ParticipantU"/>
<exchange data="U" mesh="MeshU" from="ParticipantU" to="ParticipantI"/>
</coupling-scheme:serial-implicit>

</precice-configuration>
Loading