moab-dev
Threads by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
November 2013
- 13 participants
- 87 discussions
commit/MOAB: tautges: Create a Fortran90 example that pushes mesh into parallel MOAB, then resolves shared entities
by commits-noreply@bitbucket.org 15 Nov '13
by commits-noreply@bitbucket.org 15 Nov '13
15 Nov '13
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/4f4f66bf24ff/
Changeset: 4f4f66bf24ff
Branch: tautges/push-parallel-mesh-example
User: tautges
Date: 2013-11-15 18:46:32
Summary: Create a Fortran90 example that pushes mesh into parallel MOAB, then resolves shared entities
and exchanges a ghost layer of elements.
This required a change to MOAB's iMeshP implementation of iMeshP_syncMeshAll, where a call is made to resolve_shared_ents.
This also removes ParallelComm::update_shared_mesh, which was an empty function called from syncMeshAll but didn't do anything.
Affected #: 5 files
diff --git a/examples/PushParMeshIntoMoabF90.F90 b/examples/PushParMeshIntoMoabF90.F90
new file mode 100644
index 0000000..131d19c
--- /dev/null
+++ b/examples/PushParMeshIntoMoabF90.F90
@@ -0,0 +1,281 @@
+! PushParMeshIntoMoabF90: push parallel mesh into moab, F90 version
+!
+! This program shows how to push a mesh into MOAB in parallel from Fortran90, with sufficient
+! information to resolve boundary sharing and exchange a layer of ghost information.
+! To successfully link this example, you need to specify FCFLAGS that include:
+! a) -DUSE_MPI, and
+! b) flags required to link Fortran90 MPI programs with the C++ compiler; these flags
+! can often be found on your system by inspecting the output of 'mpif90 -show'
+! For example, using gcc, the link line looks like:
+! make MOAB_DIR=<moab install dir> FCFLAGS="-DUSE_MPI -I/usr/lib/openmpi/include -pthread -I/usr/lib/openmpi/lib -L/usr/lib/openmpi/lib -lmpi_f90 -lmpi_f77 -lmpi -lopen-rte -lopen-pal -ldl -Wl,--export-dynamic -lnsl -lutil -lm -ldl" PushParMeshIntoMoabF90
+!
+! Usage: PushParMeshIntoMoab
+
+program PushParMeshIntoMoab
+
+ use ISO_C_BINDING
+ implicit none
+
+#ifdef USE_MPI
+# include "iMeshP_f.h"
+#else
+# include "iMesh_f.h"
+#endif
+
+ ! declarations
+ ! imesh is the instance handle
+ iMesh_Instance imesh
+ ! NUMV, NUME, NVPERE are the hardwired here; these are for the whole mesh,
+ ! local mesh determined later
+ integer NUMV, NUME, NVPERE
+ parameter (NUMV = 8) ! # vertices in whole mesh
+ parameter (NUME = 6) ! # elements in whole mesh
+ parameter (NVPERE = 4) ! # vertices per element
+ ! ents, verts will be arrays storing vertex/entity handles
+ iBase_EntityHandle, pointer :: ents, verts
+ iBase_EntitySetHandle root_set
+ TYPE(C_PTR) :: vertsPtr, entsPtr
+ ! storage for vertex positions, element connectivity indices, global vertex ids
+ real*8 coords(0:3*NUMV-1)
+ integer iconn(0:4*NUME-1), gids(0:NUMV-1)
+ !
+ ! local variables
+ integer lgids(0:NUMV-1), lconn(0:4*NUME-1)
+ real*8 lcoords(0:3*NUMV-1)
+ integer lnumv, lvids(0:NUMV-1), gvids(0:NUMV-1)
+ integer lvpe, ltp ! lvpe = # vertices per entity, ltp = element type
+ integer ic, ie, iv, istart, iend, ierr, indv, lnume, rank, sz
+
+#ifdef USE_MPI
+ ! local variables for parallel runs
+ iMeshP_PartitionHandle imeshp
+ integer MPI_COMM_WORLD
+#endif
+
+ ! vertex positions, latlon coords, (lat, lon, lev), fortran ordering
+ ! (first index varying fastest)
+ data coords / &
+ 0.0, -45.0, 0.0, 90.0, -45.0, 0.0, 180.0, -45.0, 0.0, 270.0, -45.0, 0.0, &
+ 0.0, 45.0, 0.0, 90.0, 45.0, 0.0, 180.0, 45.0, 0.0, 270.0, 45.0, 0.0 /
+
+ ! quad index numbering, each quad ccw, sides then bottom then top
+ data iconn / &
+ 0, 1, 5, 4, &
+ 1, 2, 6, 5, &
+ 2, 3, 7, 6, &
+ 3, 0, 4, 7, &
+ 0, 3, 2, 1, &
+ 4, 5, 6, 7 /
+
+ data lvpe /4/ ! quads in this example
+ data ltp / iMesh_QUADRILATERAL / ! from iBase_f.h
+
+ ! initialize global vertex ids
+ do iv = 0, NUMV-1
+ lgids(iv) = iv+1
+ end do
+
+#ifdef USE_MPI
+ ! init the parallel partition
+ call MPI_INIT(ierr)
+ call MPI_COMM_SIZE(MPI_COMM_WORLD, sz, ierr)
+ call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
+ ! compute starting/ending element numbers
+ lnume = NUME / sz
+ istart = rank * lnume
+ iend = istart + lnume - 1
+ if (rank .eq. sz-1) then
+ iend = NUME-1
+ lnume = iend - istart + 1
+ endif
+#else
+ ! set the starting/ending element numbers
+ istart = 0
+ iend = NUME-1
+ lnume = NUME
+#endif
+
+ ! for my elements, figure out which vertices I use and accumulate local indices and coords
+ ! lvids stores the local 0-based index for each vertex; -1 means vertex i isn't used locally
+ ! also build up connectivity indices for local elements, in lconn
+ do iv = 0, NUMV-1
+ lvids(iv) = -1
+ end do
+ lnumv = -1
+ do ie = istart, iend
+ do iv = 0, lvpe-1
+ indv = iconn(lvpe*ie + iv)
+ if (lvids(indv) .eq. -1) then
+ lnumv = lnumv + 1 ! increment local # verts
+ do ic = 0, 2 ! cache local coords
+ lcoords(3*lnumv+ic) = coords(3*indv+ic)
+ end do
+ lvids(indv) = lnumv
+ gvids(lnumv) = 1+indv
+ end if
+ lconn(lvpe*(ie-istart)+iv) = lvids(indv)
+ end do ! do iv
+ end do ! do ie
+
+ lnumv = lnumv + 1
+
+ ! now create the mesh; this also initializes parallel sharing and ghost exchange
+ imesh = 0
+ imeshp = 0
+ call create_mesh(imesh, imeshp, MPI_COMM_WORLD, lnumv, lnume, gvids, lvpe, ltp, lcoords, lconn, &
+ vertsPtr, entsPtr, ierr)
+ call c_f_pointer(vertsPtr, verts, [lnumv])
+ call c_f_pointer(entsPtr, ents, [lnume])
+
+ ! get/report number of vertices, elements
+ call iMesh_getRootSet(%VAL(imesh), root_set, ierr)
+ iv = 0
+ ie = 0
+#ifdef USE_MPI
+ call iMeshP_getNumOfTypeAll(%VAL(imesh), %VAL(imeshp), %VAL(root_set), %VAL(iBase_VERTEX), iv, ierr)
+ call iMeshP_getNumOfTypeAll(%VAL(imesh), %VAL(imeshp), %VAL(root_set), %VAL(iBase_FACE), ie, ierr)
+ if (rank .eq. 0) then
+ write(0,*) "Number of vertices = ", iv
+ write(0,*) "Number of entities = ", ie
+ endif
+#else
+ call iMesh_getNumOfTypeAll(%VAL(imesh), %VAL(root_set), %VAL(iBase_VERTEX), iv, ierr)
+ call iMesh_getNumOfTypeAll(%VAL(imesh), %VAL(root_set), %VAL(iBase_FACE), ie, ierr)
+ write(0,*) "Number of vertices = ", iv
+ write(0,*) "Number of entities = ", ie
+#endif
+
+ ! from here, can use verts and ents as (1-based) arrays of entity handles for input to other iMesh functions
+
+ call MPI_FINALIZE(ierr)
+ stop
+end program PushParMeshIntoMoab
+
+subroutine create_mesh( &
+ ! interfaces
+ imesh, imeshp, &
+ ! input
+ comm, numv, nume, vgids, nvpe, tp, posn, iconn, &
+ ! output
+ vertsPtr, entsPtr, ierr)
+ !
+ ! create a mesh with numv vertices and nume elements, with elements of type tp
+ ! vertices have positions in posn (3 coordinates each, interleaved xyzxyz...), indexed from 0
+ ! elements have nvpe vertices per entity, with connectivity indices stored in iconn, referencing
+ ! vertices using 0-based indices; vertex and entity handles are output in arrays passed in
+ !
+ ! if imesh/imeshp are 0, imesh/imeshp are initialized in this subroutine
+ !
+
+ use ISO_C_BINDING
+ implicit none
+
+#ifdef USE_MPI
+# include "iMeshP_f.h"
+# include "mpif.h"
+#else
+# include "iMesh_f.h"
+#endif
+
+ ! subroutine arguments
+ iMesh_Instance imesh
+ TYPE(C_PTR) :: vertsPtr, entsPtr
+ integer numv, nume, nvpe, vgids(0:*), iconn(0:*), ierr, tp
+ real*8 posn(0:*)
+#ifdef USE_MPI
+ iMeshP_PartitionHandle imeshp
+ integer comm
+#endif
+
+ ! local variables
+ integer comm_sz, comm_rank, numa, numo, iv, ie
+ TYPE(C_PTR) :: statsPtr
+ integer, allocatable, target :: stats(:)
+ iBase_TagHandle tagh
+ integer i
+ iBase_EntityHandle, pointer :: verts(:), ents(:)
+ iBase_EntityHandle, allocatable :: conn(:)
+ iBase_EntitySetHandle root_set
+#ifdef USE_MPI
+ IBASE_HANDLE_T mpi_comm_c
+ TYPE(C_PTR) :: partsPtr
+ iMeshP_PartHandle, pointer :: parts(:)
+ iMeshP_PartHandle part
+ integer partsa, partso
+#endif
+
+ ! create the Mesh instance
+ if (imesh .eq. 0) then
+ call iMesh_newMesh("MOAB", imesh, ierr)
+ end if
+
+#ifdef USE_MPI
+ if (imeshp .eq. 0) then
+ call iMeshP_getCommunicator(%VAL(imesh), MPI_COMM_WORLD, mpi_comm_c, ierr)
+ call iMeshP_createPartitionAll(%VAL(imesh), %VAL(mpi_comm_c), imeshp, ierr)
+ call iMeshP_createPart(%VAL(imesh), %VAL(imeshp), part, ierr)
+ else
+ partsa = 0
+ call iMeshP_getLocalParts(%VAL(imesh), %VAL(imeshp), partsPtr, partsa, partso, ierr)
+ call c_f_pointer(partsPtr, parts, [partso])
+ part = parts(1)
+ end if
+ call MPI_COMM_RANK(comm, comm_rank, ierr)
+ call MPI_COMM_SIZE(comm, comm_sz, ierr)
+#endif
+
+ ! create the vertices, all in one call
+ numa = 0
+ call iMesh_createVtxArr(%VAL(imesh), %VAL(numv), %VAL(iBase_INTERLEAVED), posn, %VAL(3*numv), &
+ vertsPtr, numa, numo, ierr)
+
+ ! fill in the connectivity array, based on indexing from iconn
+ allocate (conn(0:nvpe*nume-1))
+ call c_f_pointer(vertsPtr, verts, [numv])
+ do i = 0, nvpe*nume-1
+ conn(i) = verts(1+iconn(i))
+ end do
+ ! create the elements
+ numa = 0
+ allocate(stats(0:nume-1))
+ statsPtr = C_LOC(stats(0))
+ call iMesh_createEntArr(%VAL(imesh), %VAL(tp), conn, %VAL(nvpe*nume), &
+ entsPtr, numa, numo, statsPtr, numa, numo, ierr)
+ deallocate(stats)
+ deallocate(conn)
+
+#ifdef USE_MPI
+ ! take care of parallel stuff
+
+ ! add entities to part, using iMesh
+ call c_f_pointer(entsPtr, ents, [numo])
+ call iMesh_addEntArrToSet(%VAL(imesh), ents, %VAL(numo), %VAL(part), ierr)
+ ! set global ids on vertices, needed for sharing between procs
+ call iMesh_getTagHandle(%VAL(imesh), "GLOBAL_ID", tagh, ierr, %VAL(9))
+ if (iBase_SUCCESS .ne. ierr) then
+ ! didn't get handle, need to create the tag
+ call iMesh_createTag(%VAL(imesh), "GLOBAL_ID", %VAL(iBase_INTEGER), tagh, ierr, %VAL(9))
+ end if
+ call iMesh_setIntArrData(%VAL(imesh), verts, %VAL(numv), %VAL(tagh), vgids, %VAL(numv), ierr)
+
+ ! now resolve shared verts and exchange ghost cells
+ call iMeshP_syncMeshAll(%VAL(imesh), %VAL(imeshp), ierr)
+ call iMesh_getRootSet(%VAL(imesh), root_set, ierr)
+ call iMeshP_getNumOfTypeAll(%VAL(imesh), %VAL(imeshp), %VAL(root_set), %VAL(iBase_VERTEX), iv, ierr)
+ call iMeshP_getNumOfTypeAll(%VAL(imesh), %VAL(imeshp), %VAL(root_set), %VAL(iBase_FACE), ie, ierr)
+ if (comm_rank .eq. 0) then
+ write(0,*) "After syncMeshAll:"
+ write(0,*) " Number of vertices = ", iv
+ write(0,*) " Number of entities = ", ie
+ endif
+
+ call iMeshP_createGhostEntsAll(%VAL(imesh), %VAL(imeshp), %VAL(2), %VAL(1), %VAL(1), %VAL(0), ierr)
+ if (comm_rank .eq. 0) then
+ write(0,*) "After createGhostEntsAll:"
+ write(0,*) " Number of vertices = ", iv
+ write(0,*) " Number of entities = ", ie
+ endif
+#endif
+
+ return
+end subroutine create_mesh
diff --git a/examples/makefile b/examples/makefile
index ff5876c..cd6339e 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -9,7 +9,7 @@ MESH_DIR="../MeshFiles/unittest"
EXAMPLES = HelloMOAB GetEntities SetsNTags StructuredMeshSimple DirectAccessWithHoles DirectAccessNoHoles
PAREXAMPLES = HelloParMOAB ReduceExchangeTags LloydRelaxation
-F90EXAMPLES = DirectAccessNoHolesF90
+F90EXAMPLES = DirectAccessNoHolesF90 PushParMeshIntoMoabF90
EXOIIEXAMPLES = TestExodusII
default: ${EXAMPLES}
@@ -50,12 +50,15 @@ TestExodusII: TestExodusII.o
point_in_elem_search: point_in_elem_search.o
${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+PushParMeshIntoMoabF90: PushParMeshIntoMoabF90.o
+ ${MOAB_CXX} -o $@ $< ${IMESH_LIBS} -lgfortran -L/usr/lib/openmpi/lib -lmpi_f90 -lmpi_f77 -lmpi -lopen-rte -lopen-pal -ldl
+
clean:
rm -rf *.o ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES}
.cpp.o :
- ${MOAB_CXX} ${MOAB_CXXFLAGS} ${MOAB_INCLUDES} -DMESH_DIR=\"${MESH_DIR}\" -c $<
+ ${MOAB_CXX} ${CXXFLAGS} ${MOAB_CXXFLAGS} ${MOAB_INCLUDES} -DMESH_DIR=\"${MESH_DIR}\" -c $<
.F90.o :
- ${IMESH_FC} ${IMESH_FCFLAGS} ${IMESH_INCLUDES} ${IMESH_FCDEFS} -DMESH_DIR=\"${MESH_DIR}\" -c $<
+ ${IMESH_FC} ${FCFLAGS} ${IMESH_FCFLAGS} ${IMESH_INCLUDES} ${IMESH_FCDEFS} -DMESH_DIR=\"${MESH_DIR}\" -c $<
diff --git a/itaps/imesh/iMeshP_MOAB.cpp b/itaps/imesh/iMeshP_MOAB.cpp
index 51254ca..b7e8333 100644
--- a/itaps/imesh/iMeshP_MOAB.cpp
+++ b/itaps/imesh/iMeshP_MOAB.cpp
@@ -1606,11 +1606,8 @@ void iMeshP_syncMeshAll( iMesh_Instance instance,
const iMeshP_PartitionHandle partition_handle,
int *err )
{
- FIXME; // for now we only sync vertex coordinates
- // need to update ParallelComm::update_shared_mesh to fix this
-
ParallelComm* pcomm = PCOMM;
- ErrorCode rval = pcomm->update_shared_mesh();
+ ErrorCode rval = pcomm->resolve_shared_ents(itaps_cast<EntityHandle>(partition_handle), -1, -1);
CHKERR(rval,"update failed");
RETURN (iBase_SUCCESS);
}
diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index d92d9b1..bcc555a 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -7569,146 +7569,6 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
}
*/
- ErrorCode ParallelComm::update_shared_mesh()
- {
- // ErrorCode result;
- // int success;
-
- // ,,,
- /*
-
- // get all procs interfacing to this proc
- std::set<unsigned int> iface_procs;
- result = get_interface_procs(iface_procs);
- RRA("Failed to get iface sets, procs");
-
- // post ghost irecv's for all interface procs
- // index greqs the same as buffer/sharing procs indices
- std::vector<MPI_Request> recv_reqs(2*MAX_SHARING_PROCS, MPI_REQUEST_NULL);
- std::vector<MPI_Status> gstatus(MAX_SHARING_PROCS);
- std::set<unsigned int>::iterator sit;
- for (sit = iface_procs.begin(); sit != iface_procs.end(); sit++) {
- int ind = get_buffers(*sit);
- success = MPI_Irecv(&ghostRBuffs[ind][0], ghostRBuffs[ind].size(),
- MPI_UNSIGNED_CHAR, *sit,
- MB_MESG_ANY, procConfig.proc_comm(),
- &recv_reqs[ind]);
- if (success != MPI_SUCCESS) {
- result = MB_FAILURE;
- RRA("Failed to post irecv in ghost exchange.");
- }
- }
-
- // pack and send vertex coordinates from this proc to others
- // make sendReqs vector to simplify initialization
- std::fill(sendReqs, sendReqs+2*MAX_SHARING_PROCS, MPI_REQUEST_NULL);
- Range recd_ents[MAX_SHARING_PROCS];
-
- for (sit = iface_procs.begin(); sit != iface_procs.end(); sit++) {
- int ind = get_buffers(*sit);
-
- Range vertices;
- for (Range::iterator rit = interfaceSets.begin(); rit != interfaceSets.end();
- rit++) {
- if (!is_iface_proc(*rit, *sit))
- continue;
-
- result = mbImpl->get_entities_by_type( *rit, MBVERTEX, vertices );
- RRA("Bad interface set.");
- }
- std::map<unsigned int,Range>::iterator ghosted = ghostedEnts.find(*sit);
- if (ghosted != ghostedEnts.end()) {
- Range::iterator e = ghosted->second.upper_bound(MBVERTEX);
- vertices.merge( ghosted->second.begin(), e );
- }
-
- // pack-send; this also posts receives if store_remote_handles is true
- Range sent;
- result = pack_send_entities(*sit, vertices, false, false,
- false, true,
- ownerSBuffs[ind], ownerRBuffs[MAX_SHARING_PROCS+ind],
- sendReqs[ind], recv_reqs[MAX_SHARING_PROCS+ind],
- sent);
- RRA("Failed to pack-send in mesh update exchange.");
- }
-
- // receive/unpack entities
- // number of incoming messages depends on whether we're getting back
- // remote handles
- int num_incoming = iface_procs.size();
-
- while (num_incoming) {
- int ind;
- MPI_Status status;
- success = MPI_Waitany(2*MAX_SHARING_PROCS, &recv_reqs[0], &ind, &status);
- if (MPI_SUCCESS != success) {
- result = MB_FAILURE;
- RRA("Failed in waitany in ghost exchange.");
- }
-
- // ok, received something; decrement incoming counter
- num_incoming--;
-
- std::vector<EntityHandle> remote_handles_v, sent_ents_tmp;
- Range remote_handles_r;
- int new_size;
-
- // branch on message type
- switch (status.MPI_TAG) {
- case MB_MESG_SIZE:
- // incoming message just has size; resize buffer and re-call recv,
- // then re-increment incoming count
- assert(ind < MAX_SHARING_PROCS);
- new_size = *((int*)&ghostRBuffs[ind][0]);
- assert(0 > new_size);
- result = recv_size_buff(buffProcs[ind], ghostRBuffs[ind], recv_reqs[ind],
- MB_MESG_ENTS);
- RRA("Failed to resize recv buffer.");
- num_incoming++;
- break;
- case MB_MESG_ENTS:
- // incoming ghost entities; process
- result = recv_unpack_entities(buffProcs[ind], true,
- false,
- ghostRBuffs[ind], ghostSBuffs[ind],
- sendReqs[ind], recd_ents[ind]);
- RRA("Failed to recv-unpack message.");
- break;
- }
- }
-
- // ok, now wait if requested
- MPI_Status status[2*MAX_SHARING_PROCS];
- success = MPI_Waitall(2*MAX_SHARING_PROCS, &sendReqs[0], status);
- if (MPI_SUCCESS != success) {
- result = MB_FAILURE;
- RRA("Failure in waitall in ghost exchange.");
- }
-
- return MB_SUCCESS;
- }
- ErrorCode ParallelComm::update_iface_sets(Range &sent_ents,
- std::vector<EntityHandle> &remote_handles,
- int from_proc)
- {
- std::vector<EntityHandle>::iterator remote_it = remote_handles.begin();
- Range::iterator sent_it = sent_ents.begin();
- Range ents_to_remove;
- for (; sent_it != sent_ents.end(); sent_it++, remote_it++) {
- if (!*remote_it) ents_to_remove.insert(*sent_it);
- }
-
- for (Range::iterator set_it = interfaceSets.begin(); set_it != interfaceSets.end(); set_it++) {
- if (!is_iface_proc(*set_it, from_proc)) continue;
- ErrorCode result = mbImpl->remove_entities(*set_it, ents_to_remove);
- RRA("Couldn't remove entities from iface set in update_iface_sets.");
- }
-
- */
-
- return MB_SUCCESS;
- }
-
//! return sharedp tag
Tag ParallelComm::sharedp_tag()
{
diff --git a/src/parallel/moab/ParallelComm.hpp b/src/parallel/moab/ParallelComm.hpp
index e4217ce..3424c51 100644
--- a/src/parallel/moab/ParallelComm.hpp
+++ b/src/parallel/moab/ParallelComm.hpp
@@ -697,10 +697,6 @@ namespace moab {
int& num_part_ids_out,
EntityHandle remote_handles[MAX_SHARING_PROCS] = 0);
- // Propogate mesh modification amongst shared entities
- // from the onwing processor to any procs with copies.
- ErrorCode update_shared_mesh();
-
/** Filter the entities by pstatus tag.
* op is one of PSTATUS_ AND, OR, NOT; an entity is output if:
* AND: all bits set in pstatus_val are also set on entity
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/MOAB: tautges: Merge branch 'tautges/par-owner-fix'
by commits-noreply@bitbucket.org 15 Nov '13
by commits-noreply@bitbucket.org 15 Nov '13
15 Nov '13
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/ded02f43e94d/
Changeset: ded02f43e94d
Branch: master
User: tautges
Date: 2013-11-15 18:33:46
Summary: Merge branch 'tautges/par-owner-fix'
Conflicts:
test/parallel/parallel_unit_tests.cpp
Affected #: 3 files
diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 8efc777..d92d9b1 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -2093,7 +2093,19 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
if (new_h && store_remote_handles) {
unsigned char new_pstat = 0x0;
- if (is_iface) new_pstat = PSTATUS_INTERFACE;
+ if (is_iface) {
+ new_pstat = PSTATUS_INTERFACE;
+ // here, lowest rank proc should be first
+ int idx = std::min_element(&ps[0], &ps[0]+num_ps) - &ps[0];
+ if (idx) {
+ std::swap(ps[0], ps[idx]);
+ std::swap(hs[0], hs[idx]);
+ }
+ // set ownership based on lowest rank; can't be in update_remote_data, because
+ // there we don't know whether it resulted from ghosting or not
+ if ((num_ps > 1 && ps[0] != (int) rank()))
+ new_pstat |= PSTATUS_NOT_OWNED;
+ }
else if (created_here) {
if (created_iface) new_pstat = PSTATUS_NOT_OWNED;
else new_pstat = PSTATUS_GHOST | PSTATUS_NOT_OWNED;
@@ -2542,17 +2554,14 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
}
// add myself, if it isn't there already
- idx = 0;
- if (new_ps[0] != (int)rank()) {
- idx = std::find(&new_ps[0], &new_ps[0] + new_numps, rank()) - &new_ps[0];
- if (idx == new_numps) {
- new_ps[new_numps] = rank();
- new_hs[new_numps] = new_h;
- new_numps++;
- }
- else if (!new_hs[idx] && new_numps > 2)
- new_hs[idx] = new_h;
+ idx = std::find(&new_ps[0], &new_ps[0] + new_numps, rank()) - &new_ps[0];
+ if (idx == new_numps) {
+ new_ps[new_numps] = rank();
+ new_hs[new_numps] = new_h;
+ new_numps++;
}
+ else if (!new_hs[idx] && new_numps > 2)
+ new_hs[idx] = new_h;
// proc list is complete; update for shared, multishared
if (new_numps > 1) {
@@ -2560,18 +2569,6 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
new_pstat |= PSTATUS_SHARED;
}
- // if multishared, not ghost or interface, and not not_owned, I'm owned, and should be the first proc
- assert(new_ps[idx] == (int)rank());
- if ((new_numps > 2 && !(new_pstat&(PSTATUS_INTERFACE|PSTATUS_GHOST|PSTATUS_NOT_OWNED))) ||
- (new_pstat&PSTATUS_INTERFACE && !(new_pstat&PSTATUS_NOT_OWNED))
- ) {
- idx = std::min_element(&new_ps[0], &new_ps[0] + new_numps) - &new_ps[0];
- std::swap(new_ps[0], new_ps[idx]);
- std::swap(new_hs[0], new_hs[idx]);
- if (new_ps[0] != (int)rank())
- new_pstat |= PSTATUS_NOT_OWNED;
- }
-
/*
plist("new_ps", new_ps, new_numps);
plist("new_hs", new_hs, new_numps);
@@ -3723,15 +3720,21 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
return result;
}
}
-
- // get the entities in the partition sets
- for (Range::iterator rit = partitionSets.begin(); rit != partitionSets.end(); rit++) {
- Range tmp_ents;
- result = mbImpl->get_entities_by_handle(*rit, tmp_ents, true);
+
+ if (0 == this_set) {
+ // get the entities in the partition sets
+ for (Range::iterator rit = partitionSets.begin(); rit != partitionSets.end(); rit++) {
+ Range tmp_ents;
+ result = mbImpl->get_entities_by_handle(*rit, tmp_ents, true);
+ if (MB_SUCCESS != result) return result;
+ proc_ents.merge(tmp_ents);
+ }
+ }
+ else {
+ result = mbImpl->get_entities_by_handle(this_set, proc_ents, true);
if (MB_SUCCESS != result) return result;
- proc_ents.merge(tmp_ents);
}
-
+
// resolve dim is maximal dim of entities in proc_ents
if (-1 == resolve_dim) {
if (proc_ents.empty())
@@ -8414,7 +8417,8 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
continue;
}
- if (!shents.empty()) check_my_shared_handles(shents);
+ if (!shents.empty())
+ result = check_my_shared_handles(shents);
done = true;
}
@@ -8586,6 +8590,7 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
Range bad_ents, local_shared;
std::vector<SharedEntityData>::iterator vit;
+ unsigned char tmp_pstat;
for (unsigned int i = 0; i < shents.size(); i++) {
int other_proc = buffProcs[i];
result = get_shared_entities(other_proc, local_shared);
@@ -8596,6 +8601,11 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
result = get_remote_handles(true, &localh, &dumh, 1, other_proc, dum_vec);
if (MB_SUCCESS != result || dumh != remoteh)
bad_ents.insert(localh);
+ result = get_pstatus(localh, tmp_pstat);
+ if (MB_SUCCESS != result ||
+ (!tmp_pstat&PSTATUS_NOT_OWNED && vit->owner != rank()) ||
+ (tmp_pstat&PSTATUS_NOT_OWNED && vit->owner == rank()))
+ bad_ents.insert(localh);
}
if (!local_shared.empty())
@@ -8603,10 +8613,9 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
}
if (!bad_ents.empty()) {
- if (prefix) {
+ if (prefix)
std::cout << prefix << std::endl;
- list_entities(bad_ents);
- }
+ list_entities(bad_ents);
return MB_FAILURE;
}
diff --git a/test/parallel/parallel_unit_tests.cpp b/test/parallel/parallel_unit_tests.cpp
index 85cc3b8..d2d4c5b 100644
--- a/test/parallel/parallel_unit_tests.cpp
+++ b/test/parallel/parallel_unit_tests.cpp
@@ -1445,12 +1445,11 @@ template <typename T> ErrorCode check_shared_ents(ParallelComm &pcomm, Tag tagh,
for (rit = shared_ents.begin(); rit != shared_ents.end(); rit++, i++) {
rval = pcomm.get_sharing_data(*rit, &shprocs[0], &shhandles[0], pstatus, np); CHKERR(rval);
if (1 == np && shprocs[0] != (int) pcomm.proc_config().proc_rank()) np++;
+ bool with_root = std::find(&shprocs[0], &shprocs[np], 0)-&shprocs[0] != np || !pcomm.rank();
if (mpi_op == MPI_SUM) {if (dum_vals[i] != fact*np) return MB_FAILURE;}
else if (mpi_op == MPI_PROD) {if (dum_vals[i] != pow(fact, np)) return MB_FAILURE;}
- else if (mpi_op == MPI_MAX) {if (pcomm.rank() && std::find(&shprocs[0],&shprocs[np], 0) != &shprocs[np] &&
- dum_vals[i] != fact) return MB_FAILURE;}
- else if (mpi_op == MPI_MIN) {if (pcomm.rank() && std::find(&shprocs[0],&shprocs[np], 0) != &shprocs[np] &&
- dum_vals[i] != fact) return MB_FAILURE;}
+ else if (mpi_op == MPI_MAX) {if (with_root && dum_vals[i] != fact) return MB_FAILURE;}
+ else if (mpi_op == MPI_MIN) {if (with_root && dum_vals[i] != fact) return MB_FAILURE;}
else return MB_FAILURE;
}
diff --git a/test/parallel/structured3.cpp b/test/parallel/structured3.cpp
index 17ad177..daf065b 100644
--- a/test/parallel/structured3.cpp
+++ b/test/parallel/structured3.cpp
@@ -14,6 +14,12 @@ using namespace moab;
// Number of cells in each direction:
int NC;
+
+/* This mesh creates a box that is NCxNCxNC in global dimension, partitioned among processors
+ * automatically using ScdInterface's SQIJK algorithm. It checks to make sure there are enough
+ * procs to support this partition method. After mesh creation, shared vertex resolution is done,
+ * then ghost exchange is done.
+ */
const int ITERS = 50;
void create_parallel_mesh();
@@ -60,7 +66,7 @@ void create_parallel_mesh()
times[0] = MPI_Wtime();
rval = scdi->construct_box(HomCoord(), HomCoord(), NULL, 0, // no vertex positions
new_box, NULL, // not locally periodic
- &par_data, true, false); // assign global ids & resolve shared verts
+ &par_data, true, false); // assign global ids, don't resolve shared verts
CHECK_ERR(rval);
// get global id tag
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/MOAB: tautges: Put some comments in structured3 about what kind of mesh is created.
by commits-noreply@bitbucket.org 15 Nov '13
by commits-noreply@bitbucket.org 15 Nov '13
15 Nov '13
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/cfbd8c74d184/
Changeset: cfbd8c74d184
Branch: tautges/par-owner-fix
User: tautges
Date: 2013-11-15 18:28:10
Summary: Put some comments in structured3 about what kind of mesh is created.
Affected #: 1 file
diff --git a/test/parallel/structured3.cpp b/test/parallel/structured3.cpp
index 17ad177..daf065b 100644
--- a/test/parallel/structured3.cpp
+++ b/test/parallel/structured3.cpp
@@ -14,6 +14,12 @@ using namespace moab;
// Number of cells in each direction:
int NC;
+
+/* This mesh creates a box that is NCxNCxNC in global dimension, partitioned among processors
+ * automatically using ScdInterface's SQIJK algorithm. It checks to make sure there are enough
+ * procs to support this partition method. After mesh creation, shared vertex resolution is done,
+ * then ghost exchange is done.
+ */
const int ITERS = 50;
void create_parallel_mesh();
@@ -60,7 +66,7 @@ void create_parallel_mesh()
times[0] = MPI_Wtime();
rval = scdi->construct_box(HomCoord(), HomCoord(), NULL, 0, // no vertex positions
new_box, NULL, // not locally periodic
- &par_data, true, false); // assign global ids & resolve shared verts
+ &par_data, true, false); // assign global ids, don't resolve shared verts
CHECK_ERR(rval);
// get global id tag
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/MOAB: tautges: 1. In unpack_entities, for interface entities, make sure lowest-rank proc is first.
by commits-noreply@bitbucket.org 15 Nov '13
by commits-noreply@bitbucket.org 15 Nov '13
15 Nov '13
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/2dab7c2381f9/
Changeset: 2dab7c2381f9
Branch: tautges/par-owner-fix
User: tautges
Date: 2013-11-15 18:03:42
Summary: 1. In unpack_entities, for interface entities, make sure lowest-rank proc is first.
2. If # sharing procs > 1 and 1st proc is not my rank, set PSTATUS_NOT_OWNED bit.
These two things implement the rule in resolve_shared_ents that
interface entities are owned by lowest-rank proc sharing them. Implemented here and not in update_remote_data because there
you can't tell whether call is from ghosting or interface resolution.
3. In update_remote_data, search for my proc even when it's the first one, to make sure check for 0 handle
is done even when I'm the owner.
4. Correct parallel_unit_test test for reduce_tags and max/min; in case where np > 2, you may not be
sharing with root, in such case you won't see max/min
Affected #: 2 files
diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 8efc777..d92d9b1 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -2093,7 +2093,19 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
if (new_h && store_remote_handles) {
unsigned char new_pstat = 0x0;
- if (is_iface) new_pstat = PSTATUS_INTERFACE;
+ if (is_iface) {
+ new_pstat = PSTATUS_INTERFACE;
+ // here, lowest rank proc should be first
+ int idx = std::min_element(&ps[0], &ps[0]+num_ps) - &ps[0];
+ if (idx) {
+ std::swap(ps[0], ps[idx]);
+ std::swap(hs[0], hs[idx]);
+ }
+ // set ownership based on lowest rank; can't be in update_remote_data, because
+ // there we don't know whether it resulted from ghosting or not
+ if ((num_ps > 1 && ps[0] != (int) rank()))
+ new_pstat |= PSTATUS_NOT_OWNED;
+ }
else if (created_here) {
if (created_iface) new_pstat = PSTATUS_NOT_OWNED;
else new_pstat = PSTATUS_GHOST | PSTATUS_NOT_OWNED;
@@ -2542,17 +2554,14 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
}
// add myself, if it isn't there already
- idx = 0;
- if (new_ps[0] != (int)rank()) {
- idx = std::find(&new_ps[0], &new_ps[0] + new_numps, rank()) - &new_ps[0];
- if (idx == new_numps) {
- new_ps[new_numps] = rank();
- new_hs[new_numps] = new_h;
- new_numps++;
- }
- else if (!new_hs[idx] && new_numps > 2)
- new_hs[idx] = new_h;
+ idx = std::find(&new_ps[0], &new_ps[0] + new_numps, rank()) - &new_ps[0];
+ if (idx == new_numps) {
+ new_ps[new_numps] = rank();
+ new_hs[new_numps] = new_h;
+ new_numps++;
}
+ else if (!new_hs[idx] && new_numps > 2)
+ new_hs[idx] = new_h;
// proc list is complete; update for shared, multishared
if (new_numps > 1) {
@@ -2560,18 +2569,6 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
new_pstat |= PSTATUS_SHARED;
}
- // if multishared, not ghost or interface, and not not_owned, I'm owned, and should be the first proc
- assert(new_ps[idx] == (int)rank());
- if ((new_numps > 2 && !(new_pstat&(PSTATUS_INTERFACE|PSTATUS_GHOST|PSTATUS_NOT_OWNED))) ||
- (new_pstat&PSTATUS_INTERFACE && !(new_pstat&PSTATUS_NOT_OWNED))
- ) {
- idx = std::min_element(&new_ps[0], &new_ps[0] + new_numps) - &new_ps[0];
- std::swap(new_ps[0], new_ps[idx]);
- std::swap(new_hs[0], new_hs[idx]);
- if (new_ps[0] != (int)rank())
- new_pstat |= PSTATUS_NOT_OWNED;
- }
-
/*
plist("new_ps", new_ps, new_numps);
plist("new_hs", new_hs, new_numps);
@@ -3723,15 +3720,21 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
return result;
}
}
-
- // get the entities in the partition sets
- for (Range::iterator rit = partitionSets.begin(); rit != partitionSets.end(); rit++) {
- Range tmp_ents;
- result = mbImpl->get_entities_by_handle(*rit, tmp_ents, true);
+
+ if (0 == this_set) {
+ // get the entities in the partition sets
+ for (Range::iterator rit = partitionSets.begin(); rit != partitionSets.end(); rit++) {
+ Range tmp_ents;
+ result = mbImpl->get_entities_by_handle(*rit, tmp_ents, true);
+ if (MB_SUCCESS != result) return result;
+ proc_ents.merge(tmp_ents);
+ }
+ }
+ else {
+ result = mbImpl->get_entities_by_handle(this_set, proc_ents, true);
if (MB_SUCCESS != result) return result;
- proc_ents.merge(tmp_ents);
}
-
+
// resolve dim is maximal dim of entities in proc_ents
if (-1 == resolve_dim) {
if (proc_ents.empty())
@@ -8414,7 +8417,8 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
continue;
}
- if (!shents.empty()) check_my_shared_handles(shents);
+ if (!shents.empty())
+ result = check_my_shared_handles(shents);
done = true;
}
@@ -8586,6 +8590,7 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
Range bad_ents, local_shared;
std::vector<SharedEntityData>::iterator vit;
+ unsigned char tmp_pstat;
for (unsigned int i = 0; i < shents.size(); i++) {
int other_proc = buffProcs[i];
result = get_shared_entities(other_proc, local_shared);
@@ -8596,6 +8601,11 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
result = get_remote_handles(true, &localh, &dumh, 1, other_proc, dum_vec);
if (MB_SUCCESS != result || dumh != remoteh)
bad_ents.insert(localh);
+ result = get_pstatus(localh, tmp_pstat);
+ if (MB_SUCCESS != result ||
+ (!tmp_pstat&PSTATUS_NOT_OWNED && vit->owner != rank()) ||
+ (tmp_pstat&PSTATUS_NOT_OWNED && vit->owner == rank()))
+ bad_ents.insert(localh);
}
if (!local_shared.empty())
@@ -8603,10 +8613,9 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
}
if (!bad_ents.empty()) {
- if (prefix) {
+ if (prefix)
std::cout << prefix << std::endl;
- list_entities(bad_ents);
- }
+ list_entities(bad_ents);
return MB_FAILURE;
}
diff --git a/test/parallel/parallel_unit_tests.cpp b/test/parallel/parallel_unit_tests.cpp
index 45ef1c5..944c845 100644
--- a/test/parallel/parallel_unit_tests.cpp
+++ b/test/parallel/parallel_unit_tests.cpp
@@ -1445,10 +1445,11 @@ template <typename T> ErrorCode check_shared_ents(ParallelComm &pcomm, Tag tagh,
for (rit = shared_ents.begin(); rit != shared_ents.end(); rit++, i++) {
rval = pcomm.get_sharing_data(*rit, &shprocs[0], &shhandles[0], pstatus, np); CHKERR(rval);
if (1 == np && shprocs[0] != (int) pcomm.proc_config().proc_rank()) np++;
+ bool with_root = std::find(&shprocs[0], &shprocs[np], 0)-&shprocs[0] != np;
if (mpi_op == MPI_SUM) {if (dum_vals[i] != fact*np) return MB_FAILURE;}
else if (mpi_op == MPI_PROD) {if (dum_vals[i] != pow(fact, np)) return MB_FAILURE;}
- else if (mpi_op == MPI_MAX) {if (dum_vals[i] != fact) return MB_FAILURE;}
- else if (mpi_op == MPI_MIN) {if (dum_vals[i] != fact) return MB_FAILURE;}
+ else if (mpi_op == MPI_MAX) {if (with_root && dum_vals[i] != fact) return MB_FAILURE;}
+ else if (mpi_op == MPI_MIN) {if (with_root && dum_vals[i] != fact) return MB_FAILURE;}
else return MB_FAILURE;
}
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
2 new commits in MOAB:
https://bitbucket.org/fathomteam/moab/commits/d7a5a2be5184/
Changeset: d7a5a2be5184
Branch: None
User: tautges
Date: 2013-11-14 22:33:51
Summary: Fix parallel_unit_test so it works for 4 procs as well as 2 (not all entities are only pairwise-shared).
Add an MPI_Finalize to scdtest in case of error.
Affected #: 2 files
diff --git a/test/parallel/parallel_unit_tests.cpp b/test/parallel/parallel_unit_tests.cpp
index 45ef1c5..85cc3b8 100644
--- a/test/parallel/parallel_unit_tests.cpp
+++ b/test/parallel/parallel_unit_tests.cpp
@@ -1447,8 +1447,10 @@ template <typename T> ErrorCode check_shared_ents(ParallelComm &pcomm, Tag tagh,
if (1 == np && shprocs[0] != (int) pcomm.proc_config().proc_rank()) np++;
if (mpi_op == MPI_SUM) {if (dum_vals[i] != fact*np) return MB_FAILURE;}
else if (mpi_op == MPI_PROD) {if (dum_vals[i] != pow(fact, np)) return MB_FAILURE;}
- else if (mpi_op == MPI_MAX) {if (dum_vals[i] != fact) return MB_FAILURE;}
- else if (mpi_op == MPI_MIN) {if (dum_vals[i] != fact) return MB_FAILURE;}
+ else if (mpi_op == MPI_MAX) {if (pcomm.rank() && std::find(&shprocs[0],&shprocs[np], 0) != &shprocs[np] &&
+ dum_vals[i] != fact) return MB_FAILURE;}
+ else if (mpi_op == MPI_MIN) {if (pcomm.rank() && std::find(&shprocs[0],&shprocs[np], 0) != &shprocs[np] &&
+ dum_vals[i] != fact) return MB_FAILURE;}
else return MB_FAILURE;
}
diff --git a/test/parallel/scdtest.cpp b/test/parallel/scdtest.cpp
index 3202621..5338b81 100644
--- a/test/parallel/scdtest.cpp
+++ b/test/parallel/scdtest.cpp
@@ -49,6 +49,7 @@ int main(int argc, char *argv[])
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size != 4 && size != 2) {
cerr << "Run this with 2 or 4 processes\n";
+ MPI_Finalize();
exit(1);
}
https://bitbucket.org/fathomteam/moab/commits/7c37ce441fdd/
Changeset: 7c37ce441fdd
Branch: master
User: tautges
Date: 2013-11-14 22:34:11
Summary: Merge branch 'master' of bitbucket.org:fathomteam/moab
Affected #: 8 files
diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index be91ef8..ebf149c 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -10,10 +10,10 @@
#include "MBTagConventions.hpp"
#define ERRORR(rval, str) \
- if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
+ if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
#define ERRORS(err, str) \
- if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
+ if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
namespace moab {
@@ -315,8 +315,10 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
ReadNC::VarData vd = (*mit).second;
- // This variable will not be read
- if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end())
+ // No need to read ignored variables. Upon creation of dummy variables,
+ // tag values have already been set
+ if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end() ||
+ dummyVarNames.find(vd.varName) != dummyVarNames.end())
continue;
if (vd.entLoc == ReadNC::ENTLOCSET)
@@ -331,8 +333,10 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
if (mit != varInfo.end()) {
ReadNC::VarData vd = (*mit).second;
- // This variable will not be read
- if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end())
+ // No need to read ignored variables. Upon creation of dummy variables,
+ // tag values have already been set
+ if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end() ||
+ dummyVarNames.find(vd.varName) != dummyVarNames.end())
continue;
if (vd.entLoc == ReadNC::ENTLOCSET)
@@ -382,7 +386,6 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
{
- std::set<std::string>& dummyVarNames = _readNC->dummyVarNames;
Interface*& mbImpl = _readNC->mbImpl;
DebugOutput& dbgOut = _readNC->dbgOut;
@@ -392,11 +395,6 @@ ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, s
// Finally, read into that space
int success;
for (unsigned int i = 0; i < vdatas.size(); i++) {
- // This is a dummy variable for a dimension with no corresponding coordinate variable
- // No need to set its tag data
- if (dummyVarNames.find(vdatas[i].varName) != dummyVarNames.end())
- continue;
-
for (unsigned int t = 0; t < tstep_nums.size(); t++) {
void* data = vdatas[i].varDatas[t];
@@ -719,56 +717,63 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
return MB_SUCCESS;
}
-void NCHelper::init_dims_with_no_coord_vars_info()
+ErrorCode NCHelper::create_dummy_variables()
{
+ Interface*& mbImpl = _readNC->mbImpl;
std::vector<std::string>& dimNames = _readNC->dimNames;
- std::set<std::string>& dummyVarNames = _readNC->dummyVarNames;
+ std::vector<int>& dimLens = _readNC->dimLens;
std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
DebugOutput& dbgOut = _readNC->dbgOut;
// Hack: look at all dimensions, and see if we have one that does not appear in the list of varInfo names
- // Right now, candidates are from unstructured meshes, such as ncol(HOMME) and nCells(MPAS)
- // For them, create dummy tags
+ // Right now, candidates are from unstructured meshes, such as ncol (HOMME) and nCells (MPAS)
+ // For each of them, create a dummy variable with a sparse tag to store the dimension length
for (unsigned int i = 0; i < dimNames.size(); i++) {
- // If there is a variable with this dimension name, skip, we are fine; if not, create a dummy varInfo
+ // If there is a variable with this dimension name, skip
if (varInfo.find(dimNames[i]) != varInfo.end())
continue;
+ // Create a dummy variable
int sizeTotalVar = varInfo.size();
std::string var_name(dimNames[i]);
ReadNC::VarData& data = varInfo[var_name];
data.varName = std::string(var_name);
data.varId = sizeTotalVar;
data.varTags.resize(1, 0);
- data.varDataType = NC_DOUBLE; // Could be int, actually, but we do not really need the type
+ data.varDataType = NC_INT;
data.varDims.resize(1);
data.varDims[0] = (int)i;
data.numAtts = 0;
data.entLoc = ReadNC::ENTLOCSET;
- dbgOut.tprintf(2, "Dummy varInfo created for dimension %s\n", dimNames[i].c_str());
dummyVarNames.insert(dimNames[i]);
+ dbgOut.tprintf(2, "Dummy variable created for dimension %s\n", dimNames[i].c_str());
+
+ // Create a sparse tag to store the dimension length
+ Tag tagh;
+ ErrorCode rval = mbImpl->tag_get_handle(dimNames[i].c_str(), 1, MB_TYPE_INTEGER, tagh,
+ MB_TAG_SPARSE | MB_TAG_CREAT | MB_TAG_EXCL);
+ // If the tag already exists, skip
+ if (MB_ALREADY_ALLOCATED == rval)
+ continue;
+ ERRORR(rval, "Failed to create dimension tag.");
+
+ rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &dimLens[i]);
+ ERRORR(rval, "Failed to set data for dimension tag.");
+
+ dbgOut.tprintf(2, "Sparse tag created for dimension %s\n", dimNames[i].c_str());
}
+
+ return MB_SUCCESS;
}
ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
{
- std::set<std::string>& dummyVarNames = _readNC->dummyVarNames;
std::vector<int>& dimLens = _readNC->dimLens;
DebugOutput& dbgOut = _readNC->dbgOut;
ErrorCode rval = MB_SUCCESS;
for (unsigned int i = 0; i < vdatas.size(); i++) {
- // This is a dummy variable for a dimension with no corresponding coordinate variable
- // No need to allocate memory to read it
- if (dummyVarNames.find(vdatas[i].varName) != dummyVarNames.end()) {
- if (!vdatas[i].varTags[0]) {
- rval = get_tag_to_set(vdatas[i], 0, vdatas[i].varTags[0]);
- ERRORR(rval, "Trouble getting dummy tag.");
- }
- continue;
- }
-
if ((std::find(vdatas[i].varDims.begin(), vdatas[i].varDims.end(), tDim) != vdatas[i].varDims.end()))
vdatas[i].has_t = true;
@@ -893,7 +898,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
ScdParData& parData = _readNC->parData;
Range tmp_range;
- ScdBox *scd_box;
+ ScdBox* scd_box;
ErrorCode rval = scdi->construct_box(HomCoord(lDims[0], lDims[1], lDims[2], 1), HomCoord(lDims[3], lDims[4], lDims[5], 1),
NULL, 0, scd_box, locallyPeriodic, &parData, true);
@@ -1050,8 +1055,6 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
#endif
for (unsigned int i = 0; i < vdatas.size(); i++) {
- vdatas[i].numLev = nLevels;
-
for (unsigned int t = 0; t < tstep_nums.size(); t++) {
dbgOut.tprintf(2, "Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
@@ -1074,17 +1077,14 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
vdatas[i].readStarts[t].push_back(tstep_nums[t]);
vdatas[i].readCounts[t].push_back(1);
- // Next: numLev
- if (vdatas[i].numLev != 1) {
- vdatas[i].readStarts[t].push_back(0);
- vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
- }
+ // Next: numLev, even if it is 1
+ vdatas[i].readStarts[t].push_back(0);
+ vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
// Finally: y and x
switch (vdatas[i].entLoc) {
case ReadNC::ENTLOCVERT:
// Vertices
- // Only structured mesh has j parameter that multiplies i to get total # vertices
vdatas[i].readStarts[t].push_back(lDims[1]);
vdatas[i].readCounts[t].push_back(lDims[4] - lDims[1] + 1);
vdatas[i].readStarts[t].push_back(lDims[0]);
@@ -1101,8 +1101,8 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
case ReadNC::ENTLOCFACE:
// Faces
vdatas[i].readStarts[t].push_back(lCDims[1]);
- vdatas[i].readStarts[t].push_back(lCDims[0]);
vdatas[i].readCounts[t].push_back(lCDims[4] - lCDims[1] + 1);
+ vdatas[i].readStarts[t].push_back(lCDims[0]);
vdatas[i].readCounts[t].push_back(lCDims[3] - lCDims[0] + 1);
assert(vdatas[i].readStarts[t].size() == vdatas[i].varDims.size());
#ifdef USE_MPI
@@ -1245,6 +1245,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
rval = tmp_rval;
}
}
+
// Debug output, if requested
if (1 == dbgOut.get_verbosity()) {
dbgOut.printf(1, "Read variables: %s", vdatas.begin()->varName.c_str());
diff --git a/src/io/NCHelper.hpp b/src/io/NCHelper.hpp
index dcb006e..817257c 100644
--- a/src/io/NCHelper.hpp
+++ b/src/io/NCHelper.hpp
@@ -55,18 +55,18 @@ protected:
ErrorCode get_tag_to_nonset(ReadNC::VarData& var_data, int tstep_num, Tag& tagh, int num_lev);
- //! Create a character string attString of attMap. with '\0'
+ //! Create a character string attString of attMap. with '\0'
//! terminating each attribute name, ';' separating the data type
//! and value, and ';' separating one name/data type/value from
- //! the next'. attLen stores the end position for each name/data
+ //! the next'. attLen stores the end position for each name/data
//! type/ value.
ErrorCode create_attrib_string(const std::map<std::string, ReadNC::AttData>& attMap,
std::string& attString,
std::vector<int>& attLen);
- //! Initialize information for dimensions that don't have corresponding
- //! coordinate variables - this information is used for creating dummy tags
- void init_dims_with_no_coord_vars_info();
+ //! For a dimension that does not have a corresponding coordinate variable (e.g. ncol for HOMME),
+ //! create a dummy variable with a sparse tag to store the dimension length
+ ErrorCode create_dummy_variables();
private:
//! Used by read_variable_to_set()
@@ -90,8 +90,11 @@ protected:
//! Dimension numbers for time and level
int tDim, levDim;
- //! Skip unexpected variables
+ //! Ignored variables
std::set<std::string> ignoredVarNames;
+
+ //! Dummy variables
+ std::set<std::string> dummyVarNames;
};
//! Child helper class for scd mesh, e.g. CAM_EL or CAM_FV
diff --git a/src/io/NCHelperEuler.cpp b/src/io/NCHelperEuler.cpp
index 48056c6..b117921 100644
--- a/src/io/NCHelperEuler.cpp
+++ b/src/io/NCHelperEuler.cpp
@@ -6,10 +6,10 @@
#include <sstream>
#define ERRORR(rval, str) \
- if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
+ if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
#define ERRORS(err, str) \
- if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
+ if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
namespace moab {
@@ -319,13 +319,21 @@ ErrorCode NCHelperEuler::init_mesh_vals()
dbgOut.tprintf(1, "%d elements, %d vertices\n", (lDims[3] - lDims[0]) * (lDims[4] - lDims[1]), (lDims[3] - lDims[0] + 1)
* (lDims[4] - lDims[1] + 1));
- // Determine the entity location type of a variable
+ // For each variable, determine the entity location type and number of levels
std::map<std::string, ReadNC::VarData>::iterator mit;
for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
ReadNC::VarData& vd = (*mit).second;
- if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), jCDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCFACE;
+
+ vd.entLoc = ReadNC::ENTLOCSET;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+ if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) &&
+ (std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()))
+ vd.entLoc = ReadNC::ENTLOCFACE;
+ }
+
+ vd.numLev = 1;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
+ vd.numLev = nLevels;
}
// For Eul models, slon and slat are "virtual" dimensions (not defined in the file header)
@@ -451,8 +459,9 @@ ErrorCode NCHelperEuler::init_mesh_vals()
dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
}
- // Hack: create dummy tags, if needed, for dimensions with no corresponding coordinate variables
- init_dims_with_no_coord_vars_info();
+ // Hack: create dummy variables, if needed, for dimensions with no corresponding coordinate variables
+ rval = create_dummy_variables();
+ ERRORR(rval, "Failed to create dummy variables.");
return MB_SUCCESS;
}
diff --git a/src/io/NCHelperFV.cpp b/src/io/NCHelperFV.cpp
index 253d598..7725b55 100644
--- a/src/io/NCHelperFV.cpp
+++ b/src/io/NCHelperFV.cpp
@@ -6,7 +6,7 @@
#include <sstream>
#define ERRORR(rval, str) \
- if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
+ if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
namespace moab {
@@ -315,19 +315,27 @@ ErrorCode NCHelperFV::init_mesh_vals()
dbgOut.tprintf(1, "%d elements, %d vertices\n", (lDims[3] - lDims[0]) * (lDims[4] - lDims[1]), (lDims[3] - lDims[0] + 1)
* (lDims[4] - lDims[1] + 1));
- // Determine the entity location type of a variable
+ // For each variable, determine the entity location type and number of levels
std::map<std::string, ReadNC::VarData>::iterator mit;
for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
ReadNC::VarData& vd = (*mit).second;
- if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), jCDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCFACE;
- else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), iCDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCNSEDGE;
- else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), iDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCEWEDGE;
+
+ vd.entLoc = ReadNC::ENTLOCSET;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+ if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) &&
+ (std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()))
+ vd.entLoc = ReadNC::ENTLOCFACE;
+ else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jDim) != vd.varDims.end()) &&
+ (std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()))
+ vd.entLoc = ReadNC::ENTLOCNSEDGE;
+ else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()) &&
+ (std::find(vd.varDims.begin(), vd.varDims.end(), iDim) != vd.varDims.end()))
+ vd.entLoc = ReadNC::ENTLOCEWEDGE;
+ }
+
+ vd.numLev = 1;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
+ vd.numLev = nLevels;
}
std::vector<std::string> ijdimNames(4);
@@ -452,8 +460,9 @@ ErrorCode NCHelperFV::init_mesh_vals()
dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
}
- // Hack: create dummy tags, if needed, for dimensions with no corresponding coordinate variables
- init_dims_with_no_coord_vars_info();
+ // Hack: create dummy variables, if needed, for dimensions with no corresponding coordinate variables
+ rval = create_dummy_variables();
+ ERRORR(rval, "Failed to create dummy variables.");
return MB_SUCCESS;
}
diff --git a/src/io/NCHelperHOMME.cpp b/src/io/NCHelperHOMME.cpp
index be4d93f..25c4441 100644
--- a/src/io/NCHelperHOMME.cpp
+++ b/src/io/NCHelperHOMME.cpp
@@ -151,17 +151,25 @@ ErrorCode NCHelperHOMME::init_mesh_vals()
tVals.push_back((double)t);
}
- // Determine the entity location type of a variable
+ // For each variable, determine the entity location type and number of levels
std::map<std::string, ReadNC::VarData>::iterator mit;
for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
ReadNC::VarData& vd = (*mit).second;
- if ((std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), levDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCVERT;
+
+ vd.entLoc = ReadNC::ENTLOCSET;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end())
+ vd.entLoc = ReadNC::ENTLOCVERT;
+ }
+
+ vd.numLev = 1;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
+ vd.numLev = nLevels;
}
- // Hack: create dummy tags for dimensions (like ncol) with no corresponding coordinate variables
- init_dims_with_no_coord_vars_info();
+ // Hack: create dummy variables for dimensions (like ncol) with no corresponding coordinate variables
+ rval = create_dummy_variables();
+ ERRORR(rval, "Failed to create dummy variables.");
return MB_SUCCESS;
}
@@ -540,11 +548,9 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC
vdatas[i].readStarts[t].push_back(tstep_nums[t]);
vdatas[i].readCounts[t].push_back(1);
- // Next: numLev
- if (vdatas[i].numLev != 1) {
- vdatas[i].readStarts[t].push_back(0);
- vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
- }
+ // Next: numLev, even if it is 1
+ vdatas[i].readStarts[t].push_back(0);
+ vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
// Finally: nVertices
switch (vdatas[i].entLoc) {
diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index a326e52..c803bf3 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -26,8 +26,22 @@ NCHelperMPAS::NCHelperMPAS(ReadNC* readNC, int fileId, const FileOptions& opts,
, numCellGroups(0)
, createGatherSet(false)
{
- // Hack: ignore 4D variable tracers(Time, nCells, nVertLevels, nTracers)
- ignoredVarNames.insert("tracers");
+ // Ignore variables containing topological information
+ ignoredVarNames.insert("nEdgesOnEdge");
+ ignoredVarNames.insert("nEdgesOnCell");
+ ignoredVarNames.insert("edgesOnVertex");
+ ignoredVarNames.insert("cellsOnVertex");
+ ignoredVarNames.insert("verticesOnEdge");
+ ignoredVarNames.insert("edgesOnEdge");
+ ignoredVarNames.insert("cellsOnEdge");
+ ignoredVarNames.insert("verticesOnCell");
+ ignoredVarNames.insert("edgesOnCell");
+ ignoredVarNames.insert("cellsOnCell");
+
+ // Ignore variables for index conversion
+ ignoredVarNames.insert("indexToVertexID");
+ ignoredVarNames.insert("indexToEdgeID");
+ ignoredVarNames.insert("indexToCellID");
}
bool NCHelperMPAS::can_read_file(ReadNC* readNC)
@@ -144,42 +158,41 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
}
}
- // Determine the entity location type of a variable
+ // For each variable, determine the entity location type and number of levels
for (vmit = varInfo.begin(); vmit != varInfo.end(); ++vmit) {
ReadNC::VarData& vd = (*vmit).second;
- vd.entLoc = ReadNC::ENTLOCSET;
- if ((std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) &&
- (std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCVERT;
- else if ((std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) &&
- (std::find(vd.varDims.begin(), vd.varDims.end(), eDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCEDGE;
- else if ((std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) &&
- (std::find(vd.varDims.begin(), vd.varDims.end(), cDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCFACE;
- }
+ vd.entLoc = ReadNC::ENTLOCSET;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end())
+ vd.entLoc = ReadNC::ENTLOCVERT;
+ else if (std::find(vd.varDims.begin(), vd.varDims.end(), eDim) != vd.varDims.end())
+ vd.entLoc = ReadNC::ENTLOCEDGE;
+ else if (std::find(vd.varDims.begin(), vd.varDims.end(), cDim) != vd.varDims.end())
+ vd.entLoc = ReadNC::ENTLOCFACE;
+ }
- // Determine number of levels of a variable
- for (vmit = varInfo.begin(); vmit != varInfo.end(); ++vmit) {
- ReadNC::VarData& vd = (*vmit).second;
vd.numLev = 1;
-
- if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end()) {
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
vd.numLev = nLevels;
- continue;
- }
-
- for (unsigned int i = 0; i < opt_lev_dims.size(); i++) {
- if (std::find(vd.varDims.begin(), vd.varDims.end(), opt_lev_dims[i]) != vd.varDims.end()) {
- vd.numLev = dimLens[opt_lev_dims[i]];
- break;
+ else {
+ // If nVertLevels dimension is not found, try other optional levels such as nVertLevelsP1
+ for (unsigned int i = 0; i < opt_lev_dims.size(); i++) {
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), opt_lev_dims[i]) != vd.varDims.end()) {
+ vd.numLev = dimLens[opt_lev_dims[i]];
+ break;
+ }
}
}
+
+ // Hack: ignore variables with more than 3 dimensions, e.g. tracers(Time, nCells, nVertLevels, nTracers)
+ if (vd.varDims.size() > 3)
+ ignoredVarNames.insert(vd.varName);
}
- // Hack: create dummy tags for dimensions (like nCells) with no corresponding coordinate variables
- init_dims_with_no_coord_vars_info();
+ // Hack: create dummy variables for dimensions (like nCells) with no corresponding coordinate variables
+ rval = create_dummy_variables();
+ ERRORR(rval, "Failed to create dummy variables.");
return MB_SUCCESS;
}
diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index e930930..a0e02b4 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -132,16 +132,16 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
return rval;
}
else {
- // Read dimension variable by default, the ones that are also variables
- std::vector<std::string> filteredDimNames;
+ // Read dimension variables by default (the dimensions that are also variables)
+ std::vector<std::string> dim_var_names;
for (unsigned int i = 0; i < dimNames.size(); i++) {
std::map<std::string, VarData>::iterator mit = varInfo.find(dimNames[i]);
if (mit != varInfo.end())
- filteredDimNames.push_back(dimNames[i]);
+ dim_var_names.push_back(dimNames[i]);
}
- if (!filteredDimNames.empty()) {
- rval = myHelper->read_variables(filteredDimNames, tstep_nums);
+ if (!dim_var_names.empty()) {
+ rval = myHelper->read_variables(dim_var_names, tstep_nums);
if (MB_FAILURE == rval)
return rval;
}
@@ -302,7 +302,7 @@ ErrorCode ReadNC::read_header()
ERRORR(result, "Getting attributes.");
dbgOut.tprintf(1, "Read %u attributes\n", (unsigned int) globalAtts.size());
- // Read in dimensions into dimVals
+ // Read in dimensions into dimNames and dimLens
result = get_dimensions(fileId, dimNames, dimLens);
ERRORR(result, "Getting dimensions.");
dbgOut.tprintf(1, "Read %u dimensions\n", (unsigned int) dimNames.size());
diff --git a/src/io/ReadNC.hpp b/src/io/ReadNC.hpp
index fc75140..c452716 100644
--- a/src/io/ReadNC.hpp
+++ b/src/io/ReadNC.hpp
@@ -165,9 +165,6 @@ private:
//! Dimension lengths
std::vector<int> dimLens;
- //! These should be taken out when we fix the dummy var info things
- std::set<std::string> dummyVarNames;
-
//! Global attribs
std::map<std::string, AttData> globalAtts;
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/MOAB: danwu: For a dimension that does not have a corresponding coordinate variable (e.g. ncol for HOMME, nCells for MPAS), besides a sparse tag to store the dimension length, a dummy variable in ReadNC::varInfo is still needed to create some conventional tags like __<var_name>_DIMS.
by commits-noreply@bitbucket.org 14 Nov '13
by commits-noreply@bitbucket.org 14 Nov '13
14 Nov '13
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/2d57da1edae8/
Changeset: 2d57da1edae8
Branch: master
User: danwu
Date: 2013-11-14 22:13:37
Summary: For a dimension that does not have a corresponding coordinate variable (e.g. ncol for HOMME, nCells for MPAS), besides a sparse tag to store the dimension length, a dummy variable in ReadNC::varInfo is still needed to create some conventional tags like __<var_name>_DIMS.
Affected #: 7 files
diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index 18905a0..ebf149c 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -315,8 +315,10 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
ReadNC::VarData vd = (*mit).second;
- // This variable will not be read
- if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end())
+ // No need to read ignored variables. Upon creation of dummy variables,
+ // tag values have already been set
+ if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end() ||
+ dummyVarNames.find(vd.varName) != dummyVarNames.end())
continue;
if (vd.entLoc == ReadNC::ENTLOCSET)
@@ -331,8 +333,10 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
if (mit != varInfo.end()) {
ReadNC::VarData vd = (*mit).second;
- // This variable will not be read
- if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end())
+ // No need to read ignored variables. Upon creation of dummy variables,
+ // tag values have already been set
+ if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end() ||
+ dummyVarNames.find(vd.varName) != dummyVarNames.end())
continue;
if (vd.entLoc == ReadNC::ENTLOCSET)
@@ -713,7 +717,7 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
return MB_SUCCESS;
}
-ErrorCode NCHelper::create_tags_for_dims_with_no_coord_vars()
+ErrorCode NCHelper::create_dummy_variables()
{
Interface*& mbImpl = _readNC->mbImpl;
std::vector<std::string>& dimNames = _readNC->dimNames;
@@ -723,12 +727,28 @@ ErrorCode NCHelper::create_tags_for_dims_with_no_coord_vars()
// Hack: look at all dimensions, and see if we have one that does not appear in the list of varInfo names
// Right now, candidates are from unstructured meshes, such as ncol (HOMME) and nCells (MPAS)
- // For each of them, create a sparse tag with the dimension name to store the dimension length
+ // For each of them, create a dummy variable with a sparse tag to store the dimension length
for (unsigned int i = 0; i < dimNames.size(); i++) {
// If there is a variable with this dimension name, skip
if (varInfo.find(dimNames[i]) != varInfo.end())
continue;
+ // Create a dummy variable
+ int sizeTotalVar = varInfo.size();
+ std::string var_name(dimNames[i]);
+ ReadNC::VarData& data = varInfo[var_name];
+ data.varName = std::string(var_name);
+ data.varId = sizeTotalVar;
+ data.varTags.resize(1, 0);
+ data.varDataType = NC_INT;
+ data.varDims.resize(1);
+ data.varDims[0] = (int)i;
+ data.numAtts = 0;
+ data.entLoc = ReadNC::ENTLOCSET;
+ dummyVarNames.insert(dimNames[i]);
+ dbgOut.tprintf(2, "Dummy variable created for dimension %s\n", dimNames[i].c_str());
+
+ // Create a sparse tag to store the dimension length
Tag tagh;
ErrorCode rval = mbImpl->tag_get_handle(dimNames[i].c_str(), 1, MB_TYPE_INTEGER, tagh,
MB_TAG_SPARSE | MB_TAG_CREAT | MB_TAG_EXCL);
diff --git a/src/io/NCHelper.hpp b/src/io/NCHelper.hpp
index e4d37cb..817257c 100644
--- a/src/io/NCHelper.hpp
+++ b/src/io/NCHelper.hpp
@@ -55,18 +55,18 @@ protected:
ErrorCode get_tag_to_nonset(ReadNC::VarData& var_data, int tstep_num, Tag& tagh, int num_lev);
- //! Create a character string attString of attMap. with '\0'
+ //! Create a character string attString of attMap. with '\0'
//! terminating each attribute name, ';' separating the data type
//! and value, and ';' separating one name/data type/value from
- //! the next'. attLen stores the end position for each name/data
+ //! the next'. attLen stores the end position for each name/data
//! type/ value.
ErrorCode create_attrib_string(const std::map<std::string, ReadNC::AttData>& attMap,
std::string& attString,
std::vector<int>& attLen);
- //! For a dimension that does not have a corresponding coordinate variable (e.g. ncol for HOMME), create
- //! a sparse tag with the dimension name to store the dimension length
- ErrorCode create_tags_for_dims_with_no_coord_vars();
+ //! For a dimension that does not have a corresponding coordinate variable (e.g. ncol for HOMME),
+ //! create a dummy variable with a sparse tag to store the dimension length
+ ErrorCode create_dummy_variables();
private:
//! Used by read_variable_to_set()
@@ -90,8 +90,11 @@ protected:
//! Dimension numbers for time and level
int tDim, levDim;
- //! Skip unexpected variables
+ //! Ignored variables
std::set<std::string> ignoredVarNames;
+
+ //! Dummy variables
+ std::set<std::string> dummyVarNames;
};
//! Child helper class for scd mesh, e.g. CAM_EL or CAM_FV
diff --git a/src/io/NCHelperEuler.cpp b/src/io/NCHelperEuler.cpp
index f70ded1..b117921 100644
--- a/src/io/NCHelperEuler.cpp
+++ b/src/io/NCHelperEuler.cpp
@@ -459,9 +459,9 @@ ErrorCode NCHelperEuler::init_mesh_vals()
dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
}
- // Hack: create tags, if needed, for dimensions with no corresponding coordinate variables
- rval = create_tags_for_dims_with_no_coord_vars();
- ERRORR(rval, "Failed to create tags for dimensions with no coordinate variables.");
+ // Hack: create dummy variables, if needed, for dimensions with no corresponding coordinate variables
+ rval = create_dummy_variables();
+ ERRORR(rval, "Failed to create dummy variables.");
return MB_SUCCESS;
}
diff --git a/src/io/NCHelperFV.cpp b/src/io/NCHelperFV.cpp
index b640298..7725b55 100644
--- a/src/io/NCHelperFV.cpp
+++ b/src/io/NCHelperFV.cpp
@@ -460,9 +460,9 @@ ErrorCode NCHelperFV::init_mesh_vals()
dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
}
- // Hack: create tags, if needed, for dimensions with no corresponding coordinate variables
- rval = create_tags_for_dims_with_no_coord_vars();
- ERRORR(rval, "Failed to create tags for dimensions with no coordinate variables.");
+ // Hack: create dummy variables, if needed, for dimensions with no corresponding coordinate variables
+ rval = create_dummy_variables();
+ ERRORR(rval, "Failed to create dummy variables.");
return MB_SUCCESS;
}
diff --git a/src/io/NCHelperHOMME.cpp b/src/io/NCHelperHOMME.cpp
index dc586c5..25c4441 100644
--- a/src/io/NCHelperHOMME.cpp
+++ b/src/io/NCHelperHOMME.cpp
@@ -167,9 +167,9 @@ ErrorCode NCHelperHOMME::init_mesh_vals()
vd.numLev = nLevels;
}
- // Hack: create tags for dimensions (like ncol) with no corresponding coordinate variables
- rval = create_tags_for_dims_with_no_coord_vars();
- ERRORR(rval, "Failed to create tags for dimensions with no coordinate variables.");
+ // Hack: create dummy variables for dimensions (like ncol) with no corresponding coordinate variables
+ rval = create_dummy_variables();
+ ERRORR(rval, "Failed to create dummy variables.");
return MB_SUCCESS;
}
diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index b79fafb..c803bf3 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -190,9 +190,9 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
ignoredVarNames.insert(vd.varName);
}
- // Hack: create tags for dimensions (like nCells) with no corresponding coordinate variables
- rval = create_tags_for_dims_with_no_coord_vars();
- ERRORR(rval, "Failed to create tags for dimensions with no coordinate variables.");
+ // Hack: create dummy variables for dimensions (like nCells) with no corresponding coordinate variables
+ rval = create_dummy_variables();
+ ERRORR(rval, "Failed to create dummy variables.");
return MB_SUCCESS;
}
diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index d48612d..a0e02b4 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -132,16 +132,16 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
return rval;
}
else {
- // Read dimension variable by default, the ones that are also variables
- std::vector<std::string> filteredDimNames;
+ // Read dimension variables by default (the dimensions that are also variables)
+ std::vector<std::string> dim_var_names;
for (unsigned int i = 0; i < dimNames.size(); i++) {
std::map<std::string, VarData>::iterator mit = varInfo.find(dimNames[i]);
if (mit != varInfo.end())
- filteredDimNames.push_back(dimNames[i]);
+ dim_var_names.push_back(dimNames[i]);
}
- if (!filteredDimNames.empty()) {
- rval = myHelper->read_variables(filteredDimNames, tstep_nums);
+ if (!dim_var_names.empty()) {
+ rval = myHelper->read_variables(dim_var_names, tstep_nums);
if (MB_FAILURE == rval)
return rval;
}
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
Hey Moab-Dev,
I wanted to clarify my understanding of the side_number function for
polygon meshes in 2D. Specifically, given a parent-child element pair;
the function returns three parameters: side number, sense and offset.
For a face-edge pair, these parameters represent:
Side_number =the index of the edge in the array (NOT range) returned
by get_adjacencies(face,1,1,edges_associated_with_face)
Sense = the orientation of the normal of the edge with respect to the
face (ie positive for outward, negative for inward)
For a face-vertex pair, these parameter represent:
Side_number = the index of the vertex in the array (NOT range)
returned by get_adjacencies(face,1,0,vertices_associated_with_face)
Sense = 0
For an edge-vertex pair, these parameters represent:
Side_number = the index of the vertex in the array (NOT range)
returned by get_adjacencies(edge,1,0,vertices_associated_with_edge)
Sense = the orientation of the tangent of the edge with respect to the
vertex (ie positive for towards, negative for away)
Questions:
1) Is this understanding correct?
2) What does the offset parameter represent in these cases?
3) Is side_number working for meshes that contain polygons with
repeated vertices (like those used in MPAS)? My preliminary testing
based on the above understanding says no, but I wanted to check. If
not, will it be working soon?
4) Is there an iMESH function (or MOAB specific extension) that would
return similar information to side_number. I need to get access to the
information returned by side_number via Fortran 90 and iMESH is what I
am currently using to access MOAB via Fortran.
Thanks,
Chris Eldred
--
Chris Eldred
DOE Computational Science Graduate Fellow
Graduate Student, Atmospheric Science, Colorado State University
B.S. Applied Computational Physics, Carnegie Mellon University, 2009
chris.eldred(a)gmail.com / celdred(a)atmos.colostate.edu
2
3
commit/MOAB: danwu: Take out legacy dummy var info things. For a dimension that does not have a corresponding coordinate variable (e.g. ncol for HOMME, nCells for MPAS), create a sparse tag with the dimension name to store the dimension length. This is done directly in NCHelper::create_tags_for_dims_with_no_coord_vars(), and ReadNC::dummyVarNames is no longer used.
by commits-noreply@bitbucket.org 13 Nov '13
by commits-noreply@bitbucket.org 13 Nov '13
13 Nov '13
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/d96979b3285b/
Changeset: d96979b3285b
Branch: master
User: danwu
Date: 2013-11-13 22:33:13
Summary: Take out legacy dummy var info things. For a dimension that does not have a corresponding coordinate variable (e.g. ncol for HOMME, nCells for MPAS), create a sparse tag with the dimension name to store the dimension length. This is done directly in NCHelper::create_tags_for_dims_with_no_coord_vars(), and ReadNC::dummyVarNames is no longer used.
Affected #: 8 files
diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index db0bfd4..18905a0 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -382,7 +382,6 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
{
- std::set<std::string>& dummyVarNames = _readNC->dummyVarNames;
Interface*& mbImpl = _readNC->mbImpl;
DebugOutput& dbgOut = _readNC->dbgOut;
@@ -392,11 +391,6 @@ ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, s
// Finally, read into that space
int success;
for (unsigned int i = 0; i < vdatas.size(); i++) {
- // This is a dummy variable for a dimension with no corresponding coordinate variable
- // No need to set its tag data
- if (dummyVarNames.find(vdatas[i].varName) != dummyVarNames.end())
- continue;
-
for (unsigned int t = 0; t < tstep_nums.size(); t++) {
void* data = vdatas[i].varDatas[t];
@@ -719,56 +713,47 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
return MB_SUCCESS;
}
-void NCHelper::init_dims_with_no_coord_vars_info()
+ErrorCode NCHelper::create_tags_for_dims_with_no_coord_vars()
{
+ Interface*& mbImpl = _readNC->mbImpl;
std::vector<std::string>& dimNames = _readNC->dimNames;
- std::set<std::string>& dummyVarNames = _readNC->dummyVarNames;
+ std::vector<int>& dimLens = _readNC->dimLens;
std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
DebugOutput& dbgOut = _readNC->dbgOut;
// Hack: look at all dimensions, and see if we have one that does not appear in the list of varInfo names
- // Right now, candidates are from unstructured meshes, such as ncol(HOMME) and nCells(MPAS)
- // For them, create dummy tags
+ // Right now, candidates are from unstructured meshes, such as ncol (HOMME) and nCells (MPAS)
+ // For each of them, create a sparse tag with the dimension name to store the dimension length
for (unsigned int i = 0; i < dimNames.size(); i++) {
- // If there is a variable with this dimension name, skip, we are fine; if not, create a dummy varInfo
+ // If there is a variable with this dimension name, skip
if (varInfo.find(dimNames[i]) != varInfo.end())
continue;
- int sizeTotalVar = varInfo.size();
- std::string var_name(dimNames[i]);
- ReadNC::VarData& data = varInfo[var_name];
- data.varName = std::string(var_name);
- data.varId = sizeTotalVar;
- data.varTags.resize(1, 0);
- data.varDataType = NC_DOUBLE; // Could be int, actually, but we do not really need the type
- data.varDims.resize(1);
- data.varDims[0] = (int)i;
- data.numAtts = 0;
- data.entLoc = ReadNC::ENTLOCSET;
- dbgOut.tprintf(2, "Dummy varInfo created for dimension %s\n", dimNames[i].c_str());
- dummyVarNames.insert(dimNames[i]);
+ Tag tagh;
+ ErrorCode rval = mbImpl->tag_get_handle(dimNames[i].c_str(), 1, MB_TYPE_INTEGER, tagh,
+ MB_TAG_SPARSE | MB_TAG_CREAT | MB_TAG_EXCL);
+ // If the tag already exists, skip
+ if (MB_ALREADY_ALLOCATED == rval)
+ continue;
+ ERRORR(rval, "Failed to create dimension tag.");
+
+ rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &dimLens[i]);
+ ERRORR(rval, "Failed to set data for dimension tag.");
+
+ dbgOut.tprintf(2, "Sparse tag created for dimension %s\n", dimNames[i].c_str());
}
+
+ return MB_SUCCESS;
}
ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
{
- std::set<std::string>& dummyVarNames = _readNC->dummyVarNames;
std::vector<int>& dimLens = _readNC->dimLens;
DebugOutput& dbgOut = _readNC->dbgOut;
ErrorCode rval = MB_SUCCESS;
for (unsigned int i = 0; i < vdatas.size(); i++) {
- // This is a dummy variable for a dimension with no corresponding coordinate variable
- // No need to allocate memory to read it
- if (dummyVarNames.find(vdatas[i].varName) != dummyVarNames.end()) {
- if (!vdatas[i].varTags[0]) {
- rval = get_tag_to_set(vdatas[i], 0, vdatas[i].varTags[0]);
- ERRORR(rval, "Trouble getting dummy tag.");
- }
- continue;
- }
-
if ((std::find(vdatas[i].varDims.begin(), vdatas[i].varDims.end(), tDim) != vdatas[i].varDims.end()))
vdatas[i].has_t = true;
diff --git a/src/io/NCHelper.hpp b/src/io/NCHelper.hpp
index dcb006e..e4d37cb 100644
--- a/src/io/NCHelper.hpp
+++ b/src/io/NCHelper.hpp
@@ -64,9 +64,9 @@ protected:
std::string& attString,
std::vector<int>& attLen);
- //! Initialize information for dimensions that don't have corresponding
- //! coordinate variables - this information is used for creating dummy tags
- void init_dims_with_no_coord_vars_info();
+ //! For a dimension that does not have a corresponding coordinate variable (e.g. ncol for HOMME), create
+ //! a sparse tag with the dimension name to store the dimension length
+ ErrorCode create_tags_for_dims_with_no_coord_vars();
private:
//! Used by read_variable_to_set()
diff --git a/src/io/NCHelperEuler.cpp b/src/io/NCHelperEuler.cpp
index 5082c2e..f70ded1 100644
--- a/src/io/NCHelperEuler.cpp
+++ b/src/io/NCHelperEuler.cpp
@@ -459,8 +459,9 @@ ErrorCode NCHelperEuler::init_mesh_vals()
dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
}
- // Hack: create dummy tags, if needed, for dimensions with no corresponding coordinate variables
- init_dims_with_no_coord_vars_info();
+ // Hack: create tags, if needed, for dimensions with no corresponding coordinate variables
+ rval = create_tags_for_dims_with_no_coord_vars();
+ ERRORR(rval, "Failed to create tags for dimensions with no coordinate variables.");
return MB_SUCCESS;
}
diff --git a/src/io/NCHelperFV.cpp b/src/io/NCHelperFV.cpp
index 488a511..b640298 100644
--- a/src/io/NCHelperFV.cpp
+++ b/src/io/NCHelperFV.cpp
@@ -460,8 +460,9 @@ ErrorCode NCHelperFV::init_mesh_vals()
dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
}
- // Hack: create dummy tags, if needed, for dimensions with no corresponding coordinate variables
- init_dims_with_no_coord_vars_info();
+ // Hack: create tags, if needed, for dimensions with no corresponding coordinate variables
+ rval = create_tags_for_dims_with_no_coord_vars();
+ ERRORR(rval, "Failed to create tags for dimensions with no coordinate variables.");
return MB_SUCCESS;
}
diff --git a/src/io/NCHelperHOMME.cpp b/src/io/NCHelperHOMME.cpp
index ba504e6..dc586c5 100644
--- a/src/io/NCHelperHOMME.cpp
+++ b/src/io/NCHelperHOMME.cpp
@@ -167,8 +167,9 @@ ErrorCode NCHelperHOMME::init_mesh_vals()
vd.numLev = nLevels;
}
- // Hack: create dummy tags for dimensions (like ncol) with no corresponding coordinate variables
- init_dims_with_no_coord_vars_info();
+ // Hack: create tags for dimensions (like ncol) with no corresponding coordinate variables
+ rval = create_tags_for_dims_with_no_coord_vars();
+ ERRORR(rval, "Failed to create tags for dimensions with no coordinate variables.");
return MB_SUCCESS;
}
diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index 9d50ffe..b79fafb 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -190,8 +190,9 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
ignoredVarNames.insert(vd.varName);
}
- // Hack: create dummy tags for dimensions (like nCells) with no corresponding coordinate variables
- init_dims_with_no_coord_vars_info();
+ // Hack: create tags for dimensions (like nCells) with no corresponding coordinate variables
+ rval = create_tags_for_dims_with_no_coord_vars();
+ ERRORR(rval, "Failed to create tags for dimensions with no coordinate variables.");
return MB_SUCCESS;
}
diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index e930930..d48612d 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -302,7 +302,7 @@ ErrorCode ReadNC::read_header()
ERRORR(result, "Getting attributes.");
dbgOut.tprintf(1, "Read %u attributes\n", (unsigned int) globalAtts.size());
- // Read in dimensions into dimVals
+ // Read in dimensions into dimNames and dimLens
result = get_dimensions(fileId, dimNames, dimLens);
ERRORR(result, "Getting dimensions.");
dbgOut.tprintf(1, "Read %u dimensions\n", (unsigned int) dimNames.size());
diff --git a/src/io/ReadNC.hpp b/src/io/ReadNC.hpp
index fc75140..c452716 100644
--- a/src/io/ReadNC.hpp
+++ b/src/io/ReadNC.hpp
@@ -165,9 +165,6 @@ private:
//! Dimension lengths
std::vector<int> dimLens;
- //! These should be taken out when we fix the dummy var info things
- std::set<std::string> dummyVarNames;
-
//! Global attribs
std::map<std::string, AttData> globalAtts;
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/MOAB: danwu: Ignore some MPAS variables such as topological information. For all NC helpers, determine the entity location type and number of levels in init_mesh_vals(), with some minor changes.
by commits-noreply@bitbucket.org 13 Nov '13
by commits-noreply@bitbucket.org 13 Nov '13
13 Nov '13
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/527454d1564f/
Changeset: 527454d1564f
Branch: master
User: danwu
Date: 2013-11-13 20:05:40
Summary: Ignore some MPAS variables such as topological information. For all NC helpers, determine the entity location type and number of levels in init_mesh_vals(), with some minor changes.
Affected #: 5 files
diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index be91ef8..db0bfd4 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -10,10 +10,10 @@
#include "MBTagConventions.hpp"
#define ERRORR(rval, str) \
- if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
+ if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
#define ERRORS(err, str) \
- if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
+ if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
namespace moab {
@@ -893,7 +893,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
ScdParData& parData = _readNC->parData;
Range tmp_range;
- ScdBox *scd_box;
+ ScdBox* scd_box;
ErrorCode rval = scdi->construct_box(HomCoord(lDims[0], lDims[1], lDims[2], 1), HomCoord(lDims[3], lDims[4], lDims[5], 1),
NULL, 0, scd_box, locallyPeriodic, &parData, true);
@@ -1050,8 +1050,6 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
#endif
for (unsigned int i = 0; i < vdatas.size(); i++) {
- vdatas[i].numLev = nLevels;
-
for (unsigned int t = 0; t < tstep_nums.size(); t++) {
dbgOut.tprintf(2, "Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
@@ -1074,17 +1072,14 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
vdatas[i].readStarts[t].push_back(tstep_nums[t]);
vdatas[i].readCounts[t].push_back(1);
- // Next: numLev
- if (vdatas[i].numLev != 1) {
- vdatas[i].readStarts[t].push_back(0);
- vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
- }
+ // Next: numLev, even if it is 1
+ vdatas[i].readStarts[t].push_back(0);
+ vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
// Finally: y and x
switch (vdatas[i].entLoc) {
case ReadNC::ENTLOCVERT:
// Vertices
- // Only structured mesh has j parameter that multiplies i to get total # vertices
vdatas[i].readStarts[t].push_back(lDims[1]);
vdatas[i].readCounts[t].push_back(lDims[4] - lDims[1] + 1);
vdatas[i].readStarts[t].push_back(lDims[0]);
@@ -1101,8 +1096,8 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
case ReadNC::ENTLOCFACE:
// Faces
vdatas[i].readStarts[t].push_back(lCDims[1]);
- vdatas[i].readStarts[t].push_back(lCDims[0]);
vdatas[i].readCounts[t].push_back(lCDims[4] - lCDims[1] + 1);
+ vdatas[i].readStarts[t].push_back(lCDims[0]);
vdatas[i].readCounts[t].push_back(lCDims[3] - lCDims[0] + 1);
assert(vdatas[i].readStarts[t].size() == vdatas[i].varDims.size());
#ifdef USE_MPI
@@ -1245,6 +1240,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
rval = tmp_rval;
}
}
+
// Debug output, if requested
if (1 == dbgOut.get_verbosity()) {
dbgOut.printf(1, "Read variables: %s", vdatas.begin()->varName.c_str());
diff --git a/src/io/NCHelperEuler.cpp b/src/io/NCHelperEuler.cpp
index 48056c6..5082c2e 100644
--- a/src/io/NCHelperEuler.cpp
+++ b/src/io/NCHelperEuler.cpp
@@ -6,10 +6,10 @@
#include <sstream>
#define ERRORR(rval, str) \
- if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
+ if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
#define ERRORS(err, str) \
- if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
+ if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
namespace moab {
@@ -319,13 +319,21 @@ ErrorCode NCHelperEuler::init_mesh_vals()
dbgOut.tprintf(1, "%d elements, %d vertices\n", (lDims[3] - lDims[0]) * (lDims[4] - lDims[1]), (lDims[3] - lDims[0] + 1)
* (lDims[4] - lDims[1] + 1));
- // Determine the entity location type of a variable
+ // For each variable, determine the entity location type and number of levels
std::map<std::string, ReadNC::VarData>::iterator mit;
for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
ReadNC::VarData& vd = (*mit).second;
- if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), jCDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCFACE;
+
+ vd.entLoc = ReadNC::ENTLOCSET;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+ if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) &&
+ (std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()))
+ vd.entLoc = ReadNC::ENTLOCFACE;
+ }
+
+ vd.numLev = 1;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
+ vd.numLev = nLevels;
}
// For Eul models, slon and slat are "virtual" dimensions (not defined in the file header)
diff --git a/src/io/NCHelperFV.cpp b/src/io/NCHelperFV.cpp
index 253d598..488a511 100644
--- a/src/io/NCHelperFV.cpp
+++ b/src/io/NCHelperFV.cpp
@@ -6,7 +6,7 @@
#include <sstream>
#define ERRORR(rval, str) \
- if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
+ if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
namespace moab {
@@ -315,19 +315,27 @@ ErrorCode NCHelperFV::init_mesh_vals()
dbgOut.tprintf(1, "%d elements, %d vertices\n", (lDims[3] - lDims[0]) * (lDims[4] - lDims[1]), (lDims[3] - lDims[0] + 1)
* (lDims[4] - lDims[1] + 1));
- // Determine the entity location type of a variable
+ // For each variable, determine the entity location type and number of levels
std::map<std::string, ReadNC::VarData>::iterator mit;
for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
ReadNC::VarData& vd = (*mit).second;
- if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), jCDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCFACE;
- else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), iCDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCNSEDGE;
- else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), iDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCEWEDGE;
+
+ vd.entLoc = ReadNC::ENTLOCSET;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+ if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) &&
+ (std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()))
+ vd.entLoc = ReadNC::ENTLOCFACE;
+ else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jDim) != vd.varDims.end()) &&
+ (std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()))
+ vd.entLoc = ReadNC::ENTLOCNSEDGE;
+ else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()) &&
+ (std::find(vd.varDims.begin(), vd.varDims.end(), iDim) != vd.varDims.end()))
+ vd.entLoc = ReadNC::ENTLOCEWEDGE;
+ }
+
+ vd.numLev = 1;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
+ vd.numLev = nLevels;
}
std::vector<std::string> ijdimNames(4);
diff --git a/src/io/NCHelperHOMME.cpp b/src/io/NCHelperHOMME.cpp
index be4d93f..ba504e6 100644
--- a/src/io/NCHelperHOMME.cpp
+++ b/src/io/NCHelperHOMME.cpp
@@ -151,13 +151,20 @@ ErrorCode NCHelperHOMME::init_mesh_vals()
tVals.push_back((double)t);
}
- // Determine the entity location type of a variable
+ // For each variable, determine the entity location type and number of levels
std::map<std::string, ReadNC::VarData>::iterator mit;
for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
ReadNC::VarData& vd = (*mit).second;
- if ((std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
- vd.varDims.end(), levDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCVERT;
+
+ vd.entLoc = ReadNC::ENTLOCSET;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end())
+ vd.entLoc = ReadNC::ENTLOCVERT;
+ }
+
+ vd.numLev = 1;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
+ vd.numLev = nLevels;
}
// Hack: create dummy tags for dimensions (like ncol) with no corresponding coordinate variables
@@ -540,11 +547,9 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC
vdatas[i].readStarts[t].push_back(tstep_nums[t]);
vdatas[i].readCounts[t].push_back(1);
- // Next: numLev
- if (vdatas[i].numLev != 1) {
- vdatas[i].readStarts[t].push_back(0);
- vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
- }
+ // Next: numLev, even if it is 1
+ vdatas[i].readStarts[t].push_back(0);
+ vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
// Finally: nVertices
switch (vdatas[i].entLoc) {
diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index a326e52..9d50ffe 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -26,8 +26,22 @@ NCHelperMPAS::NCHelperMPAS(ReadNC* readNC, int fileId, const FileOptions& opts,
, numCellGroups(0)
, createGatherSet(false)
{
- // Hack: ignore 4D variable tracers(Time, nCells, nVertLevels, nTracers)
- ignoredVarNames.insert("tracers");
+ // Ignore variables containing topological information
+ ignoredVarNames.insert("nEdgesOnEdge");
+ ignoredVarNames.insert("nEdgesOnCell");
+ ignoredVarNames.insert("edgesOnVertex");
+ ignoredVarNames.insert("cellsOnVertex");
+ ignoredVarNames.insert("verticesOnEdge");
+ ignoredVarNames.insert("edgesOnEdge");
+ ignoredVarNames.insert("cellsOnEdge");
+ ignoredVarNames.insert("verticesOnCell");
+ ignoredVarNames.insert("edgesOnCell");
+ ignoredVarNames.insert("cellsOnCell");
+
+ // Ignore variables for index conversion
+ ignoredVarNames.insert("indexToVertexID");
+ ignoredVarNames.insert("indexToEdgeID");
+ ignoredVarNames.insert("indexToCellID");
}
bool NCHelperMPAS::can_read_file(ReadNC* readNC)
@@ -144,38 +158,36 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
}
}
- // Determine the entity location type of a variable
+ // For each variable, determine the entity location type and number of levels
for (vmit = varInfo.begin(); vmit != varInfo.end(); ++vmit) {
ReadNC::VarData& vd = (*vmit).second;
- vd.entLoc = ReadNC::ENTLOCSET;
- if ((std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) &&
- (std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCVERT;
- else if ((std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) &&
- (std::find(vd.varDims.begin(), vd.varDims.end(), eDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCEDGE;
- else if ((std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) &&
- (std::find(vd.varDims.begin(), vd.varDims.end(), cDim) != vd.varDims.end()))
- vd.entLoc = ReadNC::ENTLOCFACE;
- }
+ vd.entLoc = ReadNC::ENTLOCSET;
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end())
+ vd.entLoc = ReadNC::ENTLOCVERT;
+ else if (std::find(vd.varDims.begin(), vd.varDims.end(), eDim) != vd.varDims.end())
+ vd.entLoc = ReadNC::ENTLOCEDGE;
+ else if (std::find(vd.varDims.begin(), vd.varDims.end(), cDim) != vd.varDims.end())
+ vd.entLoc = ReadNC::ENTLOCFACE;
+ }
- // Determine number of levels of a variable
- for (vmit = varInfo.begin(); vmit != varInfo.end(); ++vmit) {
- ReadNC::VarData& vd = (*vmit).second;
vd.numLev = 1;
-
- if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end()) {
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
vd.numLev = nLevels;
- continue;
- }
-
- for (unsigned int i = 0; i < opt_lev_dims.size(); i++) {
- if (std::find(vd.varDims.begin(), vd.varDims.end(), opt_lev_dims[i]) != vd.varDims.end()) {
- vd.numLev = dimLens[opt_lev_dims[i]];
- break;
+ else {
+ // If nVertLevels dimension is not found, try other optional levels such as nVertLevelsP1
+ for (unsigned int i = 0; i < opt_lev_dims.size(); i++) {
+ if (std::find(vd.varDims.begin(), vd.varDims.end(), opt_lev_dims[i]) != vd.varDims.end()) {
+ vd.numLev = dimLens[opt_lev_dims[i]];
+ break;
+ }
}
}
+
+ // Hack: ignore variables with more than 3 dimensions, e.g. tracers(Time, nCells, nVertLevels, nTracers)
+ if (vd.varDims.size() > 3)
+ ignoredVarNames.insert(vd.varName);
}
// Hack: create dummy tags for dimensions (like nCells) with no corresponding coordinate variables
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
4 new commits in MOAB:
https://bitbucket.org/fathomteam/moab/commits/31889427adeb/
Changeset: 31889427adeb
Branch: None
User: iulian07
Date: 2013-11-13 06:57:34
Summary: use FileOptions class to set up the arguments
It is much nicer, and it also has help automatically:
for example, diffusion -h does this:
diffusion -h
Simulate a transport problem in a semi-Lagrangian formulation
This program simulates a transport problem on a sphere according to a benchmark from a Nair & Lauritzen paper.
It starts with a partitioned mesh on a sphere, add a tracer, and steps through.
The flow reverses after half time, and it should return to original configuration, if the integration was exact.
Usage: diffusion --help | [options]
Options:
-h [--help] : Show full help text
-g [--gtolerance] <val>: geometric absolute tolerance (used for point concidence on the sphere)
-i [--input_file] <arg>: input mesh file, partitioned
-O [--extra_read_options] <arg>: extra read options
-f [--field_type] <int>: field type-- 1: quasi-smooth; 2: smooth; 3: slotted cylinders (non-smooth)
-n [--num_steps] <int>: number of steps
-w [--write_debug_files]: write debugging files during simulation
-v [--write_velocity_files]: Reorder mesh to group entities by partition
-p [--write_result_in_parallel]: write tracer result files
Affected #: 1 file
diff --git a/tools/mbcslam/diffusion.cpp b/tools/mbcslam/diffusion.cpp
index ed1d120..378473e 100644
--- a/tools/mbcslam/diffusion.cpp
+++ b/tools/mbcslam/diffusion.cpp
@@ -39,6 +39,10 @@ on the sphere; see CSLAM Utils case1
#include "CslamUtils.hpp"
+const char BRIEF_DESC[] =
+ "Simulate a transport problem in a semi-Lagrangian formulation\n";
+std::ostringstream LONG_DESC;
+
// non smooth scalar field
// some input data
double gtol = 1.e-9; // this is for geometry tolerance
@@ -51,7 +55,7 @@ double T = 5;
int case_number = 1; // 1, 2 (non-divergent) 3 divergent
moab::Tag corrTag;
-bool noWrite = false;
+bool writeFiles = false;
bool parallelWrite = false;
bool velocity = false;
int field_type = 1 ; // 1 quasi smooth, 2 - smooth, 3 non-smooth,
@@ -395,7 +399,7 @@ ErrorCode compute_tracer_case1(Interface * mb, Intx2MeshOnSphere & worker, Entit
// lagr and euler are preserved
EntityHandle covering_set;
rval = worker.create_departure_mesh_3rd_alg(lagr_set, covering_set);
- if (!noWrite) // so if write
+ if (writeFiles) // so if write
{
std::stringstream newTracer;
newTracer << "Tracer" << rank << "_" << tStep << ".vtk";
@@ -414,7 +418,7 @@ ErrorCode compute_tracer_case1(Interface * mb, Intx2MeshOnSphere & worker, Entit
rval = worker.intersect_meshes(covering_set, euler_set, out_set);
CHECK_ERR(rval);
- if (!noWrite) // so if write
+ if (writeFiles) // so if write
{
std::stringstream intx_mesh;
intx_mesh << "Intx" << rank << "_" << tStep << ".vtk";
@@ -440,7 +444,7 @@ ErrorCode compute_tracer_case1(Interface * mb, Intx2MeshOnSphere & worker, Entit
rval = mb->write_file(resTrace.str().c_str(), 0, "PARALLEL=WRITE_PART", &euler_set, 1, &tagElem, 1);
}
- if (!noWrite) // so if write
+ if (writeFiles) // so if write
{
std::stringstream newIntx;
newIntx << "newIntx" << rank << "_" << tStep << ".vtk";
@@ -484,68 +488,49 @@ int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
+ LONG_DESC << "This program simulates a transport problem on a sphere"
+ " according to a benchmark from a Nair & Lauritzen paper.\n"
+ << "It starts with a partitioned mesh on a sphere, add a tracer, and steps through.\n" <<
+ "The flow reverses after half time, and it should return to original configuration, if the integration was exact. ";
+ ProgOptions opts(LONG_DESC.str(), BRIEF_DESC);
- std::string extra_read_opts;
// read a homme file, partitioned in 16 so far
std::string fileN= TestDir + "/HN16.h5m";
const char *filename_mesh1 = fileN.c_str();
- if (argc > 1)
- {
- int index = 1;
- while (index < argc)
- {
- if (!strcmp(argv[index], "-gtol")) // this is for geometry tolerance
- {
- gtol = atof(argv[++index]);
- }
-
- if (!strcmp(argv[index], "-input"))
- {
- filename_mesh1 = argv[++index];
- }
-
- if (!strcmp(argv[index], "-O"))
- {
- extra_read_opts = std::string(argv[++index]);
- }
-
- if (!strcmp(argv[index], "-f"))
- {
- field_type = atoi(argv[++index]);
- }
- if (!strcmp(argv[index], "-ns"))
- {
- numSteps = atoi(argv[++index]);
- }
-
- if (!strcmp(argv[index], "-nw"))
- {
- noWrite = true;
- }
-
- if (!strcmp(argv[index], "-v"))
- {
- velocity = true;
- }
-
- if (!strcmp(argv[index], "-pw"))
- {
- parallelWrite = true;
- }
-
- if (!strcmp(argv[index], "-h"))
- {
- std::cout << "usage: -gtol <tol> -input <file> -O <extra_read_opts> -v (output velocities) \n "
- << "-f <field_type> -h (this help) -ns <numSteps> -pw (parallel write) -nw (no dbg write) \n";
- std::cout << " field type: 1: quasi-smooth; 2: smooth; 3: slotted cylinders (non-smooth)\n";
- return 0;
- }
- index++;
- }
- }
+
+ opts.addOpt<double>("gtolerance,g",
+ "geometric absolute tolerance (used for point concidence on the sphere)", >ol);
+
+ std::string input_file;
+ opts.addOpt<std::string>("input_file,i", "input mesh file, partitioned",
+ &input_file);
+ std::string extra_read_opts;
+ opts.addOpt<std::string>("extra_read_options,O", "extra read options ",
+ &extra_read_opts);
+ //int field_type;
+ opts.addOpt<int>("field_type,f",
+ "field type-- 1: quasi-smooth; 2: smooth; 3: slotted cylinders (non-smooth)", &field_type);
+
+ opts.addOpt<int>("num_steps,n",
+ "number of steps ", &numSteps);
+
+ //bool reorder = false;
+ opts.addOpt<void>("write_debug_files,w", "write debugging files during simulation ",
+ &writeFiles);
+
+ opts.addOpt<void>("write_velocity_files,v", "Reorder mesh to group entities by partition",
+ &velocity);
+
+ opts.addOpt<void>("write_result_in_parallel,p", "write tracer result files",
+ ¶llelWrite);
+
+ opts.parseCommandLine(argc, argv);
+
+ if (!input_file.empty())
+ filename_mesh1=input_file.c_str();
// read in parallel, in the "euler_set", the initial mesh
- std::string opts = std::string("PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION")+
+ std::string optsRead = std::string("PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION")+
std::string(";PARALLEL_RESOLVE_SHARED_ENTS")+extra_read_opts;
Core moab;
Interface & mb = moab;
@@ -554,7 +539,7 @@ int main(int argc, char **argv)
rval = mb.create_meshset(MESHSET_SET, euler_set);
CHECK_ERR(rval);
- rval = mb.load_file(filename_mesh1, &euler_set, opts.c_str());
+ rval = mb.load_file(filename_mesh1, &euler_set, optsRead.c_str());
ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
CHECK_ERR(rval);
@@ -569,7 +554,7 @@ int main(int argc, char **argv)
std::cout << " case 1: use -gtol " << gtol <<
" -R " << radius << " -input " << filename_mesh1 << " -f " << field_type <<
" numSteps: " << numSteps << "\n";
- std::cout<<" write debug results: " << (noWrite ? "no" : "yes") << "\n";
+ std::cout<<" write debug results: " << (writeFiles ? "yes" : "no") << "\n";
std::cout<< " write tracer in parallel: " << ( parallelWrite ? "yes" : "no") << "\n";
std::cout <<" output velocity: " << (velocity? "yes" : "no") << "\n";
}
https://bitbucket.org/fathomteam/moab/commits/ce159c7e5cb7/
Changeset: ce159c7e5cb7
Branch: None
User: iulian07
Date: 2013-11-13 06:57:34
Summary: report area of the intersection polygons;
Affected #: 1 file
diff --git a/tools/mbcslam/Intx2MeshOnSphere.cpp b/tools/mbcslam/Intx2MeshOnSphere.cpp
index 7ea5854..a1d786b 100644
--- a/tools/mbcslam/Intx2MeshOnSphere.cpp
+++ b/tools/mbcslam/Intx2MeshOnSphere.cpp
@@ -452,6 +452,7 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
std::vector<double> newValues(rs2.size(), 0.);// initialize with 0 all of them
// area of the polygon * conc on red (old) current quantity
// finaly, divide by the area of the red
+ double check_intx_area=0.;
for (Range::iterator it= polys.begin(); it!=polys.end(); it++)
{
EntityHandle poly=*it;
@@ -465,6 +466,7 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
// big assumption here, red and blue are "parallel" ;we should have an index from
// blue to red (so a deformed blue corresponds to an arrival red)
double areap = area_spherical_element(mb, poly, R);
+ check_intx_area+=areap;
// so the departure cell at time t (blueIndex) covers a portion of a redCell
// that quantity will be transported to the redCell at time t+dt
// the blue corresponds to a red arrival
@@ -535,10 +537,17 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
ERRORR(rval, "can't set new values tag");
double total_mass=0.;
+ double total_intx_area =0;
int mpi_err = MPI_Reduce(&total_mass_local, &total_mass, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
if (MPI_SUCCESS != mpi_err) return MB_FAILURE;
+ // now reduce total area
+ mpi_err = MPI_Reduce(&check_intx_area, &total_intx_area, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
+ if (MPI_SUCCESS != mpi_err) return MB_FAILURE;
if (my_rank==0)
+ {
std::cout <<"total mass now:" << total_mass << "\n";
+ std::cout <<"check: total intersection area: (4 * M_PI * R^2): " << total_intx_area << "\n";
+ }
if (remote_cells)
{
https://bitbucket.org/fathomteam/moab/commits/9f8346f39e8a/
Changeset: 9f8346f39e8a
Branch: None
User: iulian07
Date: 2013-11-13 06:57:34
Summary: side number for padded polygons
the only problem is the edge between last node and first node;
Affected #: 1 file
diff --git a/src/Core.cpp b/src/Core.cpp
index ad6bdda..a6e6cfd 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -2971,7 +2971,7 @@ ErrorCode Core::side_number(const EntityHandle parent,
return (0 == temp_result ? MB_SUCCESS : MB_FAILURE);
}
else if (TYPE_FROM_HANDLE(parent) == MBPOLYGON) {
- // find location of 1st vertex
+ // find location of 1st vertex; this works even for padded vertices
const EntityHandle *first_v = std::find(parent_conn, parent_conn+num_parent_vertices,
child_conn[0]);
if (first_v == parent_conn+num_parent_vertices) return MB_ENTITY_NOT_FOUND;
@@ -2990,11 +2990,23 @@ ErrorCode Core::side_number(const EntityHandle parent,
else return MB_ENTITY_NOT_FOUND;
}
else if (TYPE_FROM_HANDLE(child) == MBEDGE) {
+ // determine the actual number of vertices, for the padded case
+ // the padded case could be like ABCDEFFF; num_parent_vertices=8, actual_num_parent_vertices=6
+ int actual_num_parent_vertices = num_parent_vertices;
+ while(actual_num_parent_vertices>=3 &&
+ (parent_conn[actual_num_parent_vertices-2] ==parent_conn[actual_num_parent_vertices-1] ) )
+ actual_num_parent_vertices--;
+
if (parent_conn[(sd_number+1)%num_parent_vertices] == child_conn[1])
sense = 1;
else if (parent_conn[(sd_number+num_parent_vertices-1)%num_parent_vertices] ==
- child_conn[1])
+ child_conn[1]) // this will also cover edge AF for padded case, side will be 0, sense -1
sense = -1;
+ // if edge FA in above example, we should return sd_number = 5, sense 1
+ else if ((sd_number==actual_num_parent_vertices-1) && (child_conn[1]==parent_conn[0]))
+ sense =1;
+ else
+ return MB_ENTITY_NOT_FOUND;
return MB_SUCCESS;
}
}
https://bitbucket.org/fathomteam/moab/commits/1bbc73aca065/
Changeset: 1bbc73aca065
Branch: master
User: iulian07
Date: 2013-11-13 06:57:34
Summary: use zoltan partitioning for intx_mpas
assumes that the build is configured with zoltan
it is launched in serial as a test here, so it should not matter for
make check
Affected #: 1 file
diff --git a/tools/mbcslam/intx_mpas.cpp b/tools/mbcslam/intx_mpas.cpp
index 6888cb3..570c97f 100644
--- a/tools/mbcslam/intx_mpas.cpp
+++ b/tools/mbcslam/intx_mpas.cpp
@@ -121,7 +121,7 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
std::string extra_read_opts;
- std::string fileN= TestDir + "/mpas_p8.h5m";
+ std::string fileN= TestDir + "/io/mpasx1.642.t.2.nc";
const char *filename_mesh1 = fileN.c_str();
bool flux_form = false;
if (argc > 1)
@@ -164,8 +164,8 @@ int main(int argc, char **argv)
}
}
// start copy
- std::string opts = std::string("PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION")+
- std::string(";PARALLEL_RESOLVE_SHARED_ENTS")+extra_read_opts;
+ std::string opts = std::string("PARALLEL=READ_PART;PARTITION_METHOD=RCBZOLTAN")+
+ std::string(";PARALLEL_RESOLVE_SHARED_ENTS;VARIABLE=;")+extra_read_opts;
Core moab;
Interface & mb = moab;
EntityHandle euler_set;
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0