13 #ifndef _SF_MESH_IO_EMI
14 #define _SF_MESH_IO_EMI
38 template<
class T,
class S>
39 inline void insert_points_ptsData_to_dof(
const meshdata<T, S> & mesh_original, meshdata<T, S> & mesh,
45 MPI_Comm comm = mesh_original.comm;
50 for(
size_t i=0; i<rnod_original.
size(); i++){
51 g2l_orig[rnod_original[i]] = i;
59 for(
size_t i=0; i<rnod.
size(); i++){
65 mesh.g_numpts = gmax+1;
67 mesh.xyz.resize(mesh.l_numpts*3);
69 for(
size_t eidx = 0; eidx < mesh.l_numelem; eidx++) {
70 T tag = mesh.tag[eidx];
72 for (
int n = mesh.dsp[eidx]; n < mesh.dsp[eidx+1];n++)
74 T g = l2g[mesh.con[n]];
75 T old_g = dof2vertex[g];
77 const auto local_idx = g2l[g];
78 const auto orig_idx = g2l_orig[old_g];
80 mesh.xyz[local_idx*3+0] = mesh_original.xyz[orig_idx*3+0];
81 mesh.xyz[local_idx*3+1] = mesh_original.xyz[orig_idx*3+1];
82 mesh.xyz[local_idx*3+2] = mesh_original.xyz[orig_idx*3+2];
83 dof2ptsData[g] = vertex2ptsdata[old_g];
85 if (!std::isfinite(mesh.xyz[local_idx*3+0]) ||
86 !std::isfinite(mesh.xyz[local_idx*3+1]) ||
87 !std::isfinite(mesh.xyz[local_idx*3+2]))
89 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=%lld\n",
90 static_cast<long long>(tag));
112 template<
class T,
class S>
113 inline void insert_points_to_surface_mesh(
const meshdata<T, S> & mesh_original, meshdata<T, S> & surfmesh,
119 MPI_Comm comm = mesh_original.comm;
124 for(
size_t i=0; i<rnod_original.
size(); i++){
125 g2l_orig[rnod_original[i]] = i;
134 for(
size_t i=0; i<rnod_surf.
size(); i++){
135 g2l_surf[rnod_surf[i]] = i;
136 l2g_surf[i] = rnod_surf[i];
140 surfmesh.g_numpts = gmax+1;
142 surfmesh.xyz.resize(surfmesh.l_numpts*3);
144 elemTag_surface.
resize(surfmesh.l_numelem);
145 for(
size_t eidx = 0; eidx < surfmesh.l_numelem; eidx++) {
146 T tag = surfmesh.tag[eidx];
147 elemTag_surface[eidx] = 1;
148 if(extra_tags.
find(tag) == extra_tags.
end())
149 elemTag_surface[eidx] = 2;
151 for (
int n = surfmesh.dsp[eidx]; n < surfmesh.dsp[eidx+1];n++)
153 T g = l2g_surf[surfmesh.con[n]];
154 T old_g = dof2vertex[g];
156 const auto local_idx = g2l_surf[g];
157 const auto orig_idx = g2l_orig[old_g];
159 surfmesh.xyz[local_idx*3+0] = mesh_original.xyz[orig_idx*3+0];
160 surfmesh.xyz[local_idx*3+1] = mesh_original.xyz[orig_idx*3+1];
161 surfmesh.xyz[local_idx*3+2] = mesh_original.xyz[orig_idx*3+2];
163 if (!std::isfinite(surfmesh.xyz[local_idx*3+0]) ||
164 !std::isfinite(surfmesh.xyz[local_idx*3+1]) ||
165 !std::isfinite(surfmesh.xyz[local_idx*3+2]))
167 fprintf(stderr,
"NaN detected in the surface mesh coordinates! on tag=%lld \n",
168 static_cast<long long>(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;
196 for(
size_t i=0; i<rnod_original.
size(); i++){
197 g2l_orig[rnod_original[i]] = i;
206 for(
size_t i=0; i<rnod_surf.
size(); i++){
207 g2l_surf[rnod_surf[i]] = i;
208 l2g_surf[i] = rnod_surf[i];
212 surfmesh.g_numpts = gmax+1;
214 surfmesh.xyz.resize(surfmesh.l_numpts*3);
216 for(
size_t eidx = 0; eidx < surfmesh.l_numelem; eidx++) {
217 T tag = surfmesh.tag[eidx];
219 for (
int n = surfmesh.dsp[eidx]; n < surfmesh.dsp[eidx+1];n++)
221 T g = l2g_surf[surfmesh.con[n]];
222 T old_g = dof2vertex[g];
224 const auto local_idx = g2l_surf[g];
225 const auto orig_idx = g2l_orig[old_g];
227 surfmesh.xyz[local_idx*3+0] = mesh_original.xyz[orig_idx*3+0];
228 surfmesh.xyz[local_idx*3+1] = mesh_original.xyz[orig_idx*3+1];
229 surfmesh.xyz[local_idx*3+2] = mesh_original.xyz[orig_idx*3+2];
231 if (!std::isfinite(surfmesh.xyz[local_idx*3+0]) ||
232 !std::isfinite(surfmesh.xyz[local_idx*3+1]) ||
233 !std::isfinite(surfmesh.xyz[local_idx*3+2]))
235 fprintf(stderr,
"NaN detected in the surface mesh coordinates! on tag=%lld \n",
236 static_cast<long long>(tag));
opencarp::local_index_t mesh_int_t
Functions related to mesh IO.
Starts and stops the linear algebra backend the flavor parameter selects.
#define EXIT(A)
finalize the backend, if it runs, and exit
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.