Skip to content

Commit 0273791

Browse files
authored
Merge pull request #204 from mcflugen/mcflugen/add-mask-to-mesh-add-nodes
ESMPY: Add ability to mask nodes of a Mesh This pull request adds the ability for a user to associate a node mask with an ESMPY Mesh. The Mesh.add_nodes method now accepts a keyword, node_mask, through which a user can pass a mask array of length n_nodes. Previously it was only possible to associate a mask with a mesh's elements. This new functionality follows the same pattern as Mesh.add_elements. To make this work I had to add an extra argument, nodeMask, to ESMC_MeshAddNodes and, as such, modified all existing calls to this function to include the value NULL for this extra argument (i.e. no masking).
2 parents ee9aef2 + 1400a47 commit 0273791

18 files changed

+343
-46
lines changed

src/Infrastructure/Field/tests/ESMC_FieldGridRegrid2UTest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ int main(void){
300300
//EX_UTest
301301
strcpy(name, "MeshAddNodes");
302302
strcpy(failMsg, "Did not return ESMF_SUCCESS");
303-
rc = ESMC_MeshAddNodes(mesh, num_node, nodeId, nodeCoord, nodeOwner);
303+
rc = ESMC_MeshAddNodes(mesh, num_node, nodeId, nodeCoord, nodeOwner, NULL);
304304
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
305305
//----------------------------------------------------------------------------
306306

src/Infrastructure/Field/tests/ESMC_FieldGridRegridCsrv2UTest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ int main(void){
337337
//EX_UTest
338338
strcpy(name, "MeshAddNodes");
339339
strcpy(failMsg, "Did not return ESMF_SUCCESS");
340-
rc = ESMC_MeshAddNodes(mesh, num_node, nodeId, nodeCoord, nodeOwner);
340+
rc = ESMC_MeshAddNodes(mesh, num_node, nodeId, nodeCoord, nodeOwner, NULL);
341341
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
342342
//----------------------------------------------------------------------------
343343

src/Infrastructure/Field/tests/ESMC_FieldGridRegridCsrvUTest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ int main(void){
370370
//EX_UTest
371371
strcpy(name, "MeshAddNodes");
372372
strcpy(failMsg, "Did not return ESMF_SUCCESS");
373-
rc = ESMC_MeshAddNodes(dstmesh, num_node, nodeId, nodeCoord, nodeOwner);
373+
rc = ESMC_MeshAddNodes(dstmesh, num_node, nodeId, nodeCoord, nodeOwner, NULL);
374374
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
375375
//----------------------------------------------------------------------------
376376

src/Infrastructure/Field/tests/ESMC_FieldGridRegridParUTest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ int main(void){
476476
//EX_UTest_Multi_Proc_Only
477477
strcpy(name, "MeshAddNodes");
478478
strcpy(failMsg, "Did not return ESMF_SUCCESS");
479-
rc = ESMC_MeshAddNodes(dstmesh, num_node, nodeId, nodeCoord, nodeOwner);
479+
rc = ESMC_MeshAddNodes(dstmesh, num_node, nodeId, nodeCoord, nodeOwner, NULL);
480480
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
481481
//----------------------------------------------------------------------------
482482

src/Infrastructure/Field/tests/ESMC_FieldGridRegridUTest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ int main(void){
281281
//EX_UTest
282282
strcpy(name, "MeshAddNodes");
283283
strcpy(failMsg, "Did not return ESMF_SUCCESS");
284-
rc = ESMC_MeshAddNodes(dstmesh, num_node, nodeId, nodeCoord, nodeOwner);
284+
rc = ESMC_MeshAddNodes(dstmesh, num_node, nodeId, nodeCoord, nodeOwner, NULL);
285285
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
286286
//----------------------------------------------------------------------------
287287

src/Infrastructure/Field/tests/ESMC_FieldRegridCsrvUTest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int main(void){
118118
//NEX_UTest
119119
strcpy(name, "MeshAddNodes");
120120
strcpy(failMsg, "Did not return ESMF_SUCCESS");
121-
rc = ESMC_MeshAddNodes(srcmesh, num_node_s, nodeId_s, nodeCoord_s, nodeOwner_s);
121+
rc = ESMC_MeshAddNodes(srcmesh, num_node_s, nodeId_s, nodeCoord_s, nodeOwner_s, NULL);
122122
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
123123
//----------------------------------------------------------------------------
124124

@@ -229,7 +229,7 @@ int main(void){
229229
//NEX_UTest
230230
strcpy(name, "MeshAddNodes");
231231
strcpy(failMsg, "Did not return ESMF_SUCCESS");
232-
rc = ESMC_MeshAddNodes(dstmesh, num_node_d, nodeId_d, nodeCoord_d, nodeOwner_d);
232+
rc = ESMC_MeshAddNodes(dstmesh, num_node_d, nodeId_d, nodeCoord_d, nodeOwner_d, NULL);
233233
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
234234
//----------------------------------------------------------------------------
235235

src/Infrastructure/Field/tests/ESMC_FieldRegridUTest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ int main(void){
127127
//NEX_UTest
128128
strcpy(name, "MeshAddNodes");
129129
strcpy(failMsg, "Did not return ESMF_SUCCESS");
130-
rc = ESMC_MeshAddNodes(srcmesh, num_node_s, nodeId_s, nodeCoord_s, nodeOwner_s);
130+
rc = ESMC_MeshAddNodes(srcmesh, num_node_s, nodeId_s, nodeCoord_s, nodeOwner_s, NULL);
131131
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
132132
//----------------------------------------------------------------------------
133133

@@ -233,7 +233,7 @@ int main(void){
233233
//NEX_UTest
234234
strcpy(name, "MeshAddNodes");
235235
strcpy(failMsg, "Did not return ESMF_SUCCESS");
236-
rc = ESMC_MeshAddNodes(dstmesh, num_node_d, nodeId_d, nodeCoord_d, nodeOwner_d);
236+
rc = ESMC_MeshAddNodes(dstmesh, num_node_d, nodeId_d, nodeCoord_d, nodeOwner_d, NULL);
237237
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
238238
//--------------------------------------------------------------------------- -
239239

src/Infrastructure/Field/tests/ESMC_FieldUTest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int main(void){
132132
// Add node information to the mesh
133133
strcpy(name, "MeshAddNodes");
134134
strcpy(failMsg, "Did not return ESMF_SUCCESS");
135-
rc = ESMC_MeshAddNodes(mesh, num_node, nodeId, nodeCoord, nodeOwner);
135+
rc = ESMC_MeshAddNodes(mesh, num_node, nodeId, nodeCoord, nodeOwner, NULL);
136136
ESMC_Test((rc==ESMF_SUCCESS), name, failMsg, &result, __FILE__, __LINE__, 0);
137137
//----------------------------------------------------------------------------
138138

src/Infrastructure/Mesh/include/ESMC_Mesh.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ int ESMC_MeshAddNodes(
213213
int nodeCount, // in
214214
int *nodeIds, // in
215215
double *nodeCoords, // in
216-
int *nodeOwners // in
216+
int *nodeOwners, // in
217+
int *nodeMask // in
217218
);
218219

219220
// !RETURN VALUE:

src/Infrastructure/Mesh/interface/ESMC_Mesh.C

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,22 @@ ESMC_Mesh ESMC_MeshCreateFromFile(const char *filename, int fileTypeFlag,
179179
#undef ESMC_METHOD
180180
#define ESMC_METHOD "ESMC_MeshAddNodes"
181181
int ESMC_MeshAddNodes(ESMC_Mesh mesh, int nodeCount, int *nodeIds,
182-
double *nodeCoords, int *nodeOwners){
182+
double *nodeCoords, int *nodeOwners, int *nodeMask){
183183

184184
// initialize return code; assume routine not implemented
185185
int localrc = ESMC_RC_NOT_IMPL;
186186
int rc = ESMC_RC_NOT_IMPL;
187187

188188
MeshCap *mc = static_cast<MeshCap*> (mesh.ptr);
189189

190-
// Wrap node_owners in IntArray
190+
// Wrap nodeOwners and nodeMask in IntArray
191191
InterArray<int> nodeOwnersIA(nodeOwners,nodeCount);
192+
InterArray<int> nodeMaskIA(nodeMask, nodeCount);
192193

193194
// call into ESMCI method
194195
mc->meshaddnodes(&nodeCount, nodeIds, nodeCoords, &nodeOwnersIA,
195-
NULL, &(mc->coordsys_mc), &(mc->sdim_mc), &localrc);
196+
&nodeMaskIA, &(mc->coordsys_mc), &(mc->sdim_mc), &localrc);
197+
196198
if (ESMC_LogDefault.MsgFoundError(localrc, ESMCI_ERR_PASSTHRU, ESMC_CONTEXT,
197199
&rc)) return rc;
198200

0 commit comments

Comments
 (0)