12 #pragma GCC diagnostic push
13 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
15 #pragma GCC diagnostic pop
25 using Edge = std::pair<int, int>;
43 { std::cout <<
" reindexed\n"; }
45 double xmin =
minNodes(Nodes::IDX_X);
46 double xmax =
maxNodes(Nodes::IDX_X);
48 double ymin =
minNodes(Nodes::IDX_Y);
49 double ymax =
maxNodes(Nodes::IDX_Y);
51 double zmin =
minNodes(Nodes::IDX_Z);
52 double zmax =
maxNodes(Nodes::IDX_Z);
54 l = Eigen::Vector3d(xmax - xmin, ymax - ymin, zmax - zmin);
55 c = Eigen::Vector3d(0.5 * (xmax + xmin), 0.5 * (ymax + ymin), 0.5 * (zmax + zmin));
62 long_axis = Nodes::IDX_X;
64 long_axis = Nodes::IDX_Z;
69 long_axis = Nodes::IDX_Y;
71 long_axis = Nodes::IDX_Z;
77 std::for_each(
tet.begin(),
tet.end(),
80 double vol_tet = te.calc_vol();
81 paramTetra[te.idxPrm].volume += vol_tet;
83 totalMagVol += vol_tet;
86 std::plus<>(), [](
const Tetra::prm ®ion){ return region.volume; });
91 volumeRegions[te.idxPrm].push_back(te.idx);
96 std::for_each(
tet.begin(),
tet.end(),
99 for (int i = 0; i < 3; ++i)
101 for (int j = i + 1; j < 4; ++j)
102 { edges.push_back(std::minmax(te.ind[i], te.ind[j])); }
105 std::sort(EXEC_POL,
edges.begin(),
edges.end());
106 auto last = std::unique(EXEC_POL,
edges.begin(),
edges.end());
108 edges.shrink_to_fit();
115 magTet.push_back(te.idx);
116 for (int i=0;i<4;i++)
117 { magNode[te.ind[i]] = true; }
121 for(
unsigned int i=0;i<fac.size();i++)
123 if (isMagnetic(fac[i]) && !mySets.paramFacette[fac[i].idxPrm].suppress_charges
124 && !isInMagList(magFac,fac[i]) )
125 { magFac.push_back(i); }
128 if(mySets.getFieldType() ==
R4toR3)
129 { setExtSpaceField(mySets); }
148 inline const Eigen::Vector3d
getNode_p(
const int i)
const {
return node[i].p; }
151 inline const Eigen::Vector3d
getNode_u(
const int i)
const {
return node[i].get_u(Nodes::NEXT); }
154 inline const Eigen::Vector3d
getNode_v(
const int i)
const {
return node[i].get_v(Nodes::NEXT); }
157 inline double getProj_ep(
const int i)
const {
return node[i].proj_ep();}
160 inline double getProj_eq(
const int i)
const {
return node[i].proj_eq();}
164 { node[i].d[Nodes::CURRENT].u = val; }
170 void infos(
void)
const;
175 std::for_each(EXEC_POL, node.begin(), node.end(),
180 inline void updateNode(
int i,
double vp,
double vq,
const double dt)
181 { node[i].make_evol(vp*gamma0, vq*gamma0, dt); }
186 std::for_each(EXEC_POL, node.begin(), node.end(),
203 std::vector<Facette::Fac>
fac;
206 std::vector<Tetra::Tet>
tet;
214 double readSol(
bool VERBOSE ,
215 const std::string fileName );
221 for (
int nodeIdx = 0; nodeIdx < int(node.size()); ++nodeIdx)
224 n.
d[Nodes::NEXT].
phi = 0.;
225 n.
d[Nodes::NEXT].
phiv = 0.;
228 if (!magNode[nodeIdx])
230 n.
d[Nodes::CURRENT].
u = Eigen::Vector3d(NAN, NAN, NAN);
231 n.
d[Nodes::NEXT].
u = n.
d[Nodes::CURRENT].
u;
240 n.
d[Nodes::NEXT].
u = n.
d[Nodes::CURRENT].
u;
245 std::set<int> nodeRegions;
247 for (
size_t regIdx = 1; regIdx < volumeRegions.size(); ++regIdx)
249 const std::vector<int> ®ionTetras = volumeRegions[regIdx];
250 bool node_in_region = std::any_of(EXEC_POL,
251 regionTetras.begin(), regionTetras.end(),
252 [
this, nodeIdx](
int tetIdx)
254 const Tetra::Tet &tetrahedron = tet[tetIdx];
255 for (int i = 0; i < Tetra::N; ++i)
257 if (tetrahedron.ind[i] == nodeIdx)
263 { nodeRegions.insert(regIdx); }
267 std::vector<std::string> region_names;
268 region_names.resize(nodeRegions.size());
269 std::transform(nodeRegions.begin(), nodeRegions.end(), region_names.begin(),
270 [
this](
int regIdx){ return paramTetra[regIdx].regName; });
273 n.d[Nodes::NEXT].u = n.d[Nodes::CURRENT].u;
282 int region = -1 )
const;
287 double min_dot_product = std::transform_reduce(EXEC_POL, edges.begin(), edges.end(), 1.0,
288 [](
double a,
double b){ return std::min(a, b); },
289 [
this](
const Edge edge)
291 Eigen::Vector3d m1 = getNode_u(edge.first);
292 Eigen::Vector3d m2 = getNode_u(edge.second);
295 return std::acos(min_dot_product);
304 void savesol(
const int precision ,
305 const std::string fileName ,
306 std::string
const &metadata ,
308 std::vector<Eigen::Vector3d> &s )
const;
312 inline void set(
const int i ,
313 std::function<
void(
Nodes::Node &,
const double)> what_to_set ,
315 { what_to_set(node[i], val); }
325 {
return (magNode[f.
ind[0]] && magNode[f.
ind[1]] && magNode[f.
ind[2]]); }
365 void checkMeshFile(
Settings const &mySets );
368 void readNodes(
Settings const &mySets );
371 void readTetraedrons(
Settings const &mySets );
374 void readTriangles(
Settings const &mySets );
377 void readMesh(
Settings const &mySets );
380 double doOnNodes(
const double init_val ,
382 std::function<
bool(
double,
double)> whatToDo )
const;
387 return doOnNodes(__DBL_MAX__, coord, [](
double a,
double b) {
return a < b; });
393 return doOnNodes(__DBL_MIN__, coord, [](
double a,
double b) {
return a > b; });
428 double surface(std::vector<int> &facIndices);
434 auto it = std::find_if(idxMagList.begin(),idxMagList.end(),
435 [
this,&f](
int idx) { return (fac[idx] == f); });
436 return(it != idxMagList.end());
441 void setExtSpaceField(
Settings &s );
Definition: facette.h:109
const Eigen::Vector3d getNode_p(const int i) const
Definition: mesh.h:148
void indexReorder()
Definition: mesh.cpp:48
Eigen::Vector3d l
Definition: mesh.h:194
bool isInMagList(std::vector< int > &idxMagList, Facette::Fac &f)
Definition: mesh.h:432
std::vector< int > magTet
Definition: mesh.h:337
std::vector< Eigen::Matrix< double, Nodes::DIM, Tetra::NPI > > extSpaceField
Definition: mesh.h:346
const Eigen::Vector3d getNode_u(const int i) const
Definition: mesh.h:151
void readMesh(Settings const &mySets)
Definition: read.cpp:12
int getNbFacs(void) const
Definition: mesh.h:142
Eigen::Vector3d c
Definition: mesh.h:191
mesh(Settings &mySets)
Definition: mesh.h:36
void set_node_zero_v(const int i)
Definition: mesh.h:167
void init_distrib(Settings const &mySets)
Definition: mesh.h:219
double max_angle() const
Definition: mesh.h:285
std::vector< Edge > edges
Definition: mesh.h:329
int getNbNodes(void) const
Definition: mesh.h:139
std::vector< Nodes::Node > node
Definition: mesh.h:351
bool isMagnetic(const Tetra::Tet &t)
Definition: mesh.h:321
double minNodes(const Nodes::index coord) const
Definition: mesh.h:385
std::vector< bool > magNode
Definition: mesh.h:334
std::vector< std::vector< int > > volumeRegions
Definition: mesh.h:361
bool isMagnetic(const Facette::Fac &f)
Definition: mesh.h:324
int getNodeIndex(const int i) const
Definition: mesh.h:318
double getProj_ep(const int i) const
Definition: mesh.h:157
std::vector< Tetra::Tet > tet
Definition: mesh.h:206
double maxNodes(const Nodes::index coord) const
Definition: mesh.h:391
int getNbTets(void) const
Definition: mesh.h:145
void set_node_u0(const int i, Eigen::Vector3d const &val)
Definition: mesh.h:163
void sortNodes(Nodes::index long_axis)
Definition: mesh.cpp:100
std::vector< Facette::Fac > fac
Definition: mesh.h:203
mesh(const mesh &)=delete
void setBasis(const double r)
Definition: mesh.h:173
void evolution(void)
Definition: mesh.h:184
std::vector< int > magFac
Definition: mesh.h:343
double totalMagVol
Definition: mesh.h:200
const Eigen::Vector3d getNode_v(const int i) const
Definition: mesh.h:154
std::vector< int > node_index
Definition: mesh.h:358
std::vector< Tetra::prm > & paramTetra
Definition: mesh.h:209
void updateNode(int i, double vp, double vq, const double dt)
Definition: mesh.h:180
double getProj_eq(const int i) const
Definition: mesh.h:160
double vol
Definition: mesh.h:197
mesh & operator=(const mesh &)=delete
void set(const int i, std::function< void(Nodes::Node &, const double)> what_to_set, const double val)
Definition: mesh.h:312
Container for all the settings provided by the user, with conversions to/from YAML.
Definition: settings.h:73
int verbose
Definition: settings.h:139
mag_exprType getMagType() const
Definition: settings.h:272
Eigen::Vector3d getMagnetization(const Eigen::Ref< Eigen::Vector3d > p) const
Definition: settings.h:282
int idxPrm
Definition: element.h:53
std::vector< int > ind
Definition: element.h:50
contains namespace Facette header containing Fac class, and some constants and a less_than operator t...
std::pair< int, int > Edge
Definition: mesh.h:25
constexpr double a[N][NPI]
Definition: facette.h:55
index
Definition: node.h:34
header to define struct Node
many settings to give some parameters to the solver, boundary conditions for the problem,...
@ R4toR3
Definition: settings.h:46
@ POSITION_ONLY
M(x, y, z)
Definition: settings.h:29
Eigen::Vector3d p
Definition: node.h:62
dataNode d[NB_DATANODE]
Definition: node.h:71
double phi
Definition: node.h:52
double phiv
Definition: node.h:53
Eigen::Vector3d u
Definition: node.h:50
namespace Tetra header containing Tet class, some constants, and integrales