28 #ifndef _SF_MESH_IO_EMI
29 #define _SF_MESH_IO_EMI
32 #include "petsc_utils.h"
51 template<
class T,
class S>
52 inline void insert_points_ptsData_to_dof(
const meshdata<T, S> & mesh_original, meshdata<T, S> & mesh,
58 MPI_Comm comm = mesh_original.comm;
63 for(
size_t i=0; i<rnod_original.
size(); i++){
64 g2l_orig[rnod_original[i]] = i;
72 for(
size_t i=0; i<rnod.
size(); i++){
78 mesh.g_numpts = gmax+1;
80 mesh.xyz.resize(mesh.l_numpts*3);
82 for(
size_t eidx = 0; eidx < mesh.l_numelem; eidx++) {
83 T tag = mesh.tag[eidx];
85 for (
int n = mesh.dsp[eidx]; n < mesh.dsp[eidx+1];n++)
87 T g = l2g[mesh.con[n]];
88 T old_g = dof2vertex[g];
90 const auto local_idx = g2l[g];
91 const auto orig_idx = g2l_orig[old_g];
93 mesh.xyz[local_idx*3+0] = mesh_original.xyz[orig_idx*3+0];
94 mesh.xyz[local_idx*3+1] = mesh_original.xyz[orig_idx*3+1];
95 mesh.xyz[local_idx*3+2] = mesh_original.xyz[orig_idx*3+2];
96 dof2ptsData[g] = vertex2ptsdata[old_g];
98 if (!std::isfinite(mesh.xyz[local_idx*3+0]) ||
99 !std::isfinite(mesh.xyz[local_idx*3+1]) ||
100 !std::isfinite(mesh.xyz[local_idx*3+2]))
102 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",
103 static_cast<long long>(tag));
125 template<
class T,
class S>
126 inline void insert_points_to_surface_mesh(
const meshdata<T, S> & mesh_original, meshdata<T, S> & surfmesh,
132 MPI_Comm comm = mesh_original.comm;
137 for(
size_t i=0; i<rnod_original.
size(); i++){
138 g2l_orig[rnod_original[i]] = i;
147 for(
size_t i=0; i<rnod_surf.
size(); i++){
148 g2l_surf[rnod_surf[i]] = i;
149 l2g_surf[i] = rnod_surf[i];
153 surfmesh.g_numpts = gmax+1;
155 surfmesh.xyz.resize(surfmesh.l_numpts*3);
157 elemTag_surface.
resize(surfmesh.l_numelem);
158 for(
size_t eidx = 0; eidx < surfmesh.l_numelem; eidx++) {
159 T tag = surfmesh.tag[eidx];
160 elemTag_surface[eidx] = 1;
161 if(extra_tags.
find(tag) == extra_tags.
end())
162 elemTag_surface[eidx] = 2;
164 for (
int n = surfmesh.dsp[eidx]; n < surfmesh.dsp[eidx+1];n++)
166 T g = l2g_surf[surfmesh.con[n]];
167 T old_g = dof2vertex[g];
169 const auto local_idx = g2l_surf[g];
170 const auto orig_idx = g2l_orig[old_g];
172 surfmesh.xyz[local_idx*3+0] = mesh_original.xyz[orig_idx*3+0];
173 surfmesh.xyz[local_idx*3+1] = mesh_original.xyz[orig_idx*3+1];
174 surfmesh.xyz[local_idx*3+2] = mesh_original.xyz[orig_idx*3+2];
176 if (!std::isfinite(surfmesh.xyz[local_idx*3+0]) ||
177 !std::isfinite(surfmesh.xyz[local_idx*3+1]) ||
178 !std::isfinite(surfmesh.xyz[local_idx*3+2]))
180 fprintf(stderr,
"NaN detected in the surface mesh coordinates! on tag=%lld \n",
181 static_cast<long long>(tag));
199 template<
class T,
class S>
200 inline void insert_points_to_surface_mesh(
const meshdata<T, S> & mesh_original, meshdata<T, S> & surfmesh,
204 MPI_Comm comm = mesh_original.comm;
209 for(
size_t i=0; i<rnod_original.
size(); i++){
210 g2l_orig[rnod_original[i]] = i;
219 for(
size_t i=0; i<rnod_surf.
size(); i++){
220 g2l_surf[rnod_surf[i]] = i;
221 l2g_surf[i] = rnod_surf[i];
225 surfmesh.g_numpts = gmax+1;
227 surfmesh.xyz.resize(surfmesh.l_numpts*3);
229 for(
size_t eidx = 0; eidx < surfmesh.l_numelem; eidx++) {
230 T tag = surfmesh.tag[eidx];
232 for (
int n = surfmesh.dsp[eidx]; n < surfmesh.dsp[eidx+1];n++)
234 T g = l2g_surf[surfmesh.con[n]];
235 T old_g = dof2vertex[g];
237 const auto local_idx = g2l_surf[g];
238 const auto orig_idx = g2l_orig[old_g];
240 surfmesh.xyz[local_idx*3+0] = mesh_original.xyz[orig_idx*3+0];
241 surfmesh.xyz[local_idx*3+1] = mesh_original.xyz[orig_idx*3+1];
242 surfmesh.xyz[local_idx*3+2] = mesh_original.xyz[orig_idx*3+2];
244 if (!std::isfinite(surfmesh.xyz[local_idx*3+0]) ||
245 !std::isfinite(surfmesh.xyz[local_idx*3+1]) ||
246 !std::isfinite(surfmesh.xyz[local_idx*3+2]))
248 fprintf(stderr,
"NaN detected in the surface mesh coordinates! on tag=%lld \n",
249 static_cast<long long>(tag));
opencarp::local_index_t mesh_int_t
Functions related to mesh IO.
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.