13 #ifndef _SF_MESH_IO_EMI
14 #define _SF_MESH_IO_EMI
17 #include "petsc_utils.h"
36 template<
class T,
class S>
37 inline void insert_points_ptsData_to_dof(
const meshdata<T, S> & mesh_original, meshdata<T, S> & mesh,
43 MPI_Comm comm = mesh_original.comm;
48 for(
size_t i=0; i<rnod_original.
size(); i++){
49 g2l_orig[rnod_original[i]] = i;
57 for(
size_t i=0; i<rnod.
size(); i++){
63 mesh.g_numpts = gmax+1;
65 mesh.xyz.resize(mesh.l_numpts*3);
67 for(
size_t eidx = 0; eidx < mesh.l_numelem; eidx++) {
68 T tag = mesh.tag[eidx];
70 for (
int n = mesh.dsp[eidx]; n < mesh.dsp[eidx+1];n++)
72 T g = l2g[mesh.con[n]];
73 T old_g = dof2vertex[g];
75 const auto local_idx = g2l[g];
76 const auto orig_idx = g2l_orig[old_g];
78 mesh.xyz[local_idx*3+0] = mesh_original.xyz[orig_idx*3+0];
79 mesh.xyz[local_idx*3+1] = mesh_original.xyz[orig_idx*3+1];
80 mesh.xyz[local_idx*3+2] = mesh_original.xyz[orig_idx*3+2];
81 dof2ptsData[g] = vertex2ptsdata[old_g];
83 if (!std::isfinite(mesh.xyz[local_idx*3+0]) ||
84 !std::isfinite(mesh.xyz[local_idx*3+1]) ||
85 !std::isfinite(mesh.xyz[local_idx*3+2]))
87 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",
88 static_cast<long long>(tag));
110 template<
class T,
class S>
111 inline void insert_points_to_surface_mesh(
const meshdata<T, S> & mesh_original, meshdata<T, S> & surfmesh,
117 MPI_Comm comm = mesh_original.comm;
122 for(
size_t i=0; i<rnod_original.
size(); i++){
123 g2l_orig[rnod_original[i]] = i;
132 for(
size_t i=0; i<rnod_surf.
size(); i++){
133 g2l_surf[rnod_surf[i]] = i;
134 l2g_surf[i] = rnod_surf[i];
138 surfmesh.g_numpts = gmax+1;
140 surfmesh.xyz.resize(surfmesh.l_numpts*3);
142 elemTag_surface.
resize(surfmesh.l_numelem);
143 for(
size_t eidx = 0; eidx < surfmesh.l_numelem; eidx++) {
144 T tag = surfmesh.tag[eidx];
145 elemTag_surface[eidx] = 1;
146 if(extra_tags.
find(tag) == extra_tags.
end())
147 elemTag_surface[eidx] = 2;
149 for (
int n = surfmesh.dsp[eidx]; n < surfmesh.dsp[eidx+1];n++)
151 T g = l2g_surf[surfmesh.con[n]];
152 T old_g = dof2vertex[g];
154 const auto local_idx = g2l_surf[g];
155 const auto orig_idx = g2l_orig[old_g];
157 surfmesh.xyz[local_idx*3+0] = mesh_original.xyz[orig_idx*3+0];
158 surfmesh.xyz[local_idx*3+1] = mesh_original.xyz[orig_idx*3+1];
159 surfmesh.xyz[local_idx*3+2] = mesh_original.xyz[orig_idx*3+2];
161 if (!std::isfinite(surfmesh.xyz[local_idx*3+0]) ||
162 !std::isfinite(surfmesh.xyz[local_idx*3+1]) ||
163 !std::isfinite(surfmesh.xyz[local_idx*3+2]))
165 fprintf(stderr,
"NaN detected in the surface mesh coordinates! on tag=%lld \n",
166 static_cast<long long>(tag));
184 template<
class T,
class S>
185 inline void insert_points_to_surface_mesh(
const meshdata<T, S> & mesh_original, meshdata<T, S> & surfmesh,
189 MPI_Comm comm = mesh_original.comm;
194 for(
size_t i=0; i<rnod_original.
size(); i++){
195 g2l_orig[rnod_original[i]] = i;
204 for(
size_t i=0; i<rnod_surf.
size(); i++){
205 g2l_surf[rnod_surf[i]] = i;
206 l2g_surf[i] = rnod_surf[i];
210 surfmesh.g_numpts = gmax+1;
212 surfmesh.xyz.resize(surfmesh.l_numpts*3);
214 for(
size_t eidx = 0; eidx < surfmesh.l_numelem; eidx++) {
215 T tag = surfmesh.tag[eidx];
217 for (
int n = surfmesh.dsp[eidx]; n < surfmesh.dsp[eidx+1];n++)
219 T g = l2g_surf[surfmesh.con[n]];
220 T old_g = dof2vertex[g];
222 const auto local_idx = g2l_surf[g];
223 const auto orig_idx = g2l_orig[old_g];
225 surfmesh.xyz[local_idx*3+0] = mesh_original.xyz[orig_idx*3+0];
226 surfmesh.xyz[local_idx*3+1] = mesh_original.xyz[orig_idx*3+1];
227 surfmesh.xyz[local_idx*3+2] = mesh_original.xyz[orig_idx*3+2];
229 if (!std::isfinite(surfmesh.xyz[local_idx*3+0]) ||
230 !std::isfinite(surfmesh.xyz[local_idx*3+1]) ||
231 !std::isfinite(surfmesh.xyz[local_idx*3+2]))
233 fprintf(stderr,
"NaN detected in the surface mesh coordinates! on tag=%lld \n",
234 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.