28 #ifndef _SF_MESH_IO_EMI
29 #define _SF_MESH_IO_EMI
32 #include "petsc_utils.h"
46 template<
class T,
class S>
47 inline void insert_points_ptsData_to_dof(
const meshdata<T, S> & mesh_original, meshdata<T, S> & mesh,
53 MPI_Comm comm = mesh_original.comm;
57 for(
size_t i=0; i<rnod_original.
size(); i++){
58 g2l_orig[rnod_original[i]] = i;
64 for(
size_t i=0; i<rnod.
size(); i++){
70 mesh.g_numpts = gmax+1;
74 mesh.xyz.
resize(mesh.l_numpts*3);
78 for(
size_t eidx = 0; eidx < mesh.l_numelem; eidx++) {
79 T tag = mesh.
tag[eidx];
81 for (
int n = mesh.dsp[eidx]; n < mesh.dsp[eidx+1];n++)
83 T g = l2g[mesh.con[n]];
84 T old_g = dof2vertex[g];
86 const auto local_idx = g2l[g];
87 const auto orig_idx = g2l_orig[old_g];
89 tmesh.
xyz[local_idx*3+0] = Buffxyz_orig[orig_idx*3+0];
90 tmesh.
xyz[local_idx*3+1] = Buffxyz_orig[orig_idx*3+1];
91 tmesh.
xyz[local_idx*3+2] = Buffxyz_orig[orig_idx*3+2];
92 dof2ptsData[g] = vertex2ptsdata[old_g];
94 if (!std::isfinite(tmesh.
xyz[local_idx*3+0]) ||
95 !std::isfinite(tmesh.
xyz[local_idx*3+1]) ||
96 !std::isfinite(tmesh.
xyz[local_idx*3+2]))
98 printf(
"NaN detected in coordinates of the EMI mesh after decoupling interfaces on EMI mesh while recording pts data on the EMI mesh, on Tag=%d\n",tag);
117 template<
class T,
class S>
118 inline void insert_points_to_surface_mesh(
const meshdata<T, S> & mesh_original, meshdata<T, S> & surfmesh,
124 MPI_Comm comm = mesh_original.
comm;
128 for(
size_t i=0; i<rnod_original.
size(); i++){
129 g2l_orig[rnod_original[i]] = i;
136 for(
size_t i=0; i<rnod_surf.
size(); i++){
137 g2l_surf[rnod_surf[i]] = i;
138 l2g_surf[i] = rnod_surf[i];
142 surfmesh.g_numpts = gmax+1;
146 surfmesh.xyz.
resize(surfmesh.l_numpts*3);
148 elemTag_surface.
resize(surfmesh.l_numelem);
149 for(
size_t eidx = 0; eidx < surfmesh.l_numelem; eidx++) {
150 T tag = surfmesh.tag[eidx];
151 elemTag_surface[eidx] = 1;
152 if(extra_tags.
find(tag) == extra_tags.
end())
153 elemTag_surface[eidx] = 2;
155 for (
int n = surfmesh.dsp[eidx]; n < surfmesh.dsp[eidx+1];n++)
157 T g = l2g_surf[surfmesh.con[n]];
158 T old_g = dof2vertex[g];
160 const auto local_idx = g2l_surf[g];
161 const auto orig_idx = g2l_orig[old_g];
163 surfmesh.xyz[local_idx*3+0] = Buffxyz[orig_idx*3+0];
164 surfmesh.xyz[local_idx*3+1] = Buffxyz[orig_idx*3+1];
165 surfmesh.xyz[local_idx*3+2] = Buffxyz[orig_idx*3+2];
167 if (!std::isfinite(surfmesh.xyz[local_idx*3+0]) ||
168 !std::isfinite(surfmesh.xyz[local_idx*3+1]) ||
169 !std::isfinite(surfmesh.xyz[local_idx*3+2]))
171 fprintf(stderr,
"NaN detected in the surface mesh coordinates! on tag=%d \n", tag);
186 template<
class T,
class S>
187 inline void insert_points_to_surface_mesh(
const meshdata<T, S> & mesh_original, meshdata<T, S> & surfmesh,
191 MPI_Comm comm = mesh_original.comm;
195 for(
size_t i=0; i<rnod_original.
size(); i++){
196 g2l_orig[rnod_original[i]] = i;
203 for(
size_t i=0; i<rnod_surf.
size(); i++){
204 g2l_surf[rnod_surf[i]] = i;
205 l2g_surf[i] = rnod_surf[i];
209 surfmesh.g_numpts = gmax+1;
213 surfmesh.xyz.
resize(surfmesh.l_numpts*3);
215 for(
size_t eidx = 0; eidx < surfmesh.l_numelem; eidx++) {
216 T tag = surfmesh.tag[eidx];
218 for (
int n = surfmesh.dsp[eidx]; n < surfmesh.dsp[eidx+1];n++)
220 T g = l2g_surf[surfmesh.con[n]];
221 T old_g = dof2vertex[g];
223 const auto local_idx = g2l_surf[g];
224 const auto orig_idx = g2l_orig[old_g];
226 surfmesh.xyz[local_idx*3+0] = Buffxyz[orig_idx*3+0];
227 surfmesh.xyz[local_idx*3+1] = Buffxyz[orig_idx*3+1];
228 surfmesh.xyz[local_idx*3+2] = Buffxyz[orig_idx*3+2];
230 if (!std::isfinite(surfmesh.xyz[local_idx*3+0]) ||
231 !std::isfinite(surfmesh.xyz[local_idx*3+1]) ||
232 !std::isfinite(surfmesh.xyz[local_idx*3+2]))
234 fprintf(stderr,
"NaN detected in the surface mesh coordinates! on tag=%d \n", tag);
Functions related to mesh IO.
vector< S > xyz
node cooridnates
MPI_Comm comm
the parallel mesh is defined on a MPI world
vector< T > tag
element tag
size_t size() const
The current size of the vector.
void resize(size_t n)
Resize a vector.
iterator find(const K &key)
T global_max(const vector< T > &vec, MPI_Comm comm)
Compute the global maximum of a distributed vector.
SF_nbr
Enumeration encoding the different supported numberings.