10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
13 #pragma GCC diagnostic pop
23 using Edge = std::pair<int, int>;
41 { std::cout <<
" reindexed\n"; }
43 double xmin =
minNodes(Nodes::IDX_X);
44 double xmax =
maxNodes(Nodes::IDX_X);
46 double ymin =
minNodes(Nodes::IDX_Y);
47 double ymax =
maxNodes(Nodes::IDX_Y);
49 double zmin =
minNodes(Nodes::IDX_Z);
50 double zmax =
maxNodes(Nodes::IDX_Z);
52 l = Eigen::Vector3d(xmax - xmin, ymax - ymin, zmax - zmin);
53 c = Eigen::Vector3d(0.5 * (xmax + xmin), 0.5 * (ymax + ymin), 0.5 * (zmax + zmin));
60 long_axis = Nodes::IDX_X;
62 long_axis = Nodes::IDX_Z;
67 long_axis = Nodes::IDX_Y;
69 long_axis = Nodes::IDX_Z;
75 std::for_each(
tet.begin(),
tet.end(),
78 double vol_tet = te.calc_vol();
79 paramTetra[te.idxPrm].volume += vol_tet;
81 totalMagVol += vol_tet;
84 std::plus<>(), [](
const Tetra::prm ®ion){ return region.volume; });
89 volumeRegions[te.idxPrm].push_back(te.idx);
94 std::for_each(
tet.begin(),
tet.end(),
97 for (int i = 0; i < 3; ++i)
99 for (int j = i + 1; j < 4; ++j)
100 { edges.push_back(std::minmax(te.ind[i], te.ind[j])); }
103 std::sort(EXEC_POL,
edges.begin(),
edges.end());
104 auto last = std::unique(EXEC_POL,
edges.begin(),
edges.end());
106 edges.shrink_to_fit();
113 magTet.push_back(te.idx);
114 for (int i=0;i<4;i++)
115 { magNode[te.ind[i]] = true; }
119 for(
unsigned int i=0;i<fac.size();i++)
121 if (isMagnetic(fac[i]) && !mySets.paramFacette[fac[i].idxPrm].suppress_charges
122 && !isInMagList(magFac,fac[i]) )
123 { magFac.push_back(i); }
126 if(mySets.getFieldType() ==
R4toR3)
127 { setExtSpaceField(mySets); }
146 inline const Eigen::Vector3d
getNode_p(
const int i)
const {
return node[i].p; }
149 inline const Eigen::Vector3d
getNode_u(
const int i)
const {
return node[i].get_u(Nodes::NEXT); }
152 inline const Eigen::Vector3d
getNode_v(
const int i)
const {
return node[i].get_v(Nodes::NEXT); }
155 inline double getProj_ep(
const int i)
const {
return node[i].proj_ep();}
158 inline double getProj_eq(
const int i)
const {
return node[i].proj_eq();}
162 { node[i].d[Nodes::CURRENT].u = val; }
168 void infos(
void)
const;
173 std::for_each(EXEC_POL, node.begin(), node.end(),
178 inline void updateNode(
int i,
double vp,
double vq,
const double dt)
179 { node[i].make_evol(vp*gamma0, vq*gamma0, dt); }
184 std::for_each(EXEC_POL, node.begin(), node.end(),
201 std::vector<Facette::Fac>
fac;
204 std::vector<Tetra::Tet>
tet;
212 double readSol(
bool VERBOSE ,
213 const std::string fileName );
219 for (
int nodeIdx = 0; nodeIdx < int(node.size()); ++nodeIdx)
222 n.
d[Nodes::NEXT].
phi = 0.;
223 n.
d[Nodes::NEXT].
phiv = 0.;
226 if (!magNode[nodeIdx])
228 n.
d[Nodes::CURRENT].
u = Eigen::Vector3d(NAN, NAN, NAN);
229 n.
d[Nodes::NEXT].
u = n.
d[Nodes::CURRENT].
u;
238 n.
d[Nodes::NEXT].
u = n.
d[Nodes::CURRENT].
u;
243 std::set<int> nodeRegions;
245 for (
size_t regIdx = 1; regIdx < volumeRegions.size(); ++regIdx)
247 const std::vector<int> ®ionTetras = volumeRegions[regIdx];
248 bool node_in_region = std::any_of(EXEC_POL,
249 regionTetras.begin(), regionTetras.end(),
250 [
this, nodeIdx](
int tetIdx)
252 const Tetra::Tet &tetrahedron = tet[tetIdx];
253 for (int i = 0; i < Tetra::N; ++i)
255 if (tetrahedron.ind[i] == nodeIdx)
261 { nodeRegions.insert(regIdx); }
265 std::vector<std::string> region_names;
266 region_names.resize(nodeRegions.size());
267 std::transform(nodeRegions.begin(), nodeRegions.end(), region_names.begin(),
268 [
this](
int regIdx){ return paramTetra[regIdx].regName; });
271 n.d[Nodes::NEXT].u = n.d[Nodes::CURRENT].u;
280 int region = -1 )
const;
285 double min_dot_product = std::transform_reduce(EXEC_POL, edges.begin(), edges.end(), 1.0,
286 [](
double a,
double b){ return std::min(a, b); },
287 [
this](
const Edge edge)
289 Eigen::Vector3d m1 = getNode_u(edge.first);
290 Eigen::Vector3d m2 = getNode_u(edge.second);
293 return std::acos(min_dot_product);
302 void savesol(
const int precision ,
303 const std::string fileName ,
304 std::string
const &metadata ,
306 std::vector<Eigen::Vector3d> &s )
const;
310 inline void set(
const int i ,
311 std::function<
void(
Nodes::Node &,
const double)> what_to_set ,
313 { what_to_set(node[i], val); }
323 {
return (magNode[f.
ind[0]] && magNode[f.
ind[1]] && magNode[f.
ind[2]]); }
362 void checkMeshFile(
Settings const &mySets );
365 void readNodes(
Settings const &mySets );
368 void readTetraedrons(
Settings const &mySets );
371 void readTriangles(
Settings const &mySets );
374 void readMesh(
Settings const &mySets );
377 double doOnNodes(
const double init_val ,
379 std::function<
bool(
double,
double)> whatToDo )
const;
384 return doOnNodes(__DBL_MAX__, coord, [](
double a,
double b) {
return a < b; });
390 return doOnNodes(__DBL_MIN__, coord, [](
double a,
double b) {
return a > b; });
425 double surface(std::vector<int> &facIndices);
430 auto it = std::find_if(idxMagList.begin(),idxMagList.end(),
431 [
this,&f](
int idx) { return (fac[idx] == f); });
432 return(it != idxMagList.end());
437 void setExtSpaceField(
Settings &s );
Definition: facette.h:105
const Eigen::Vector3d getNode_p(const int i) const
Definition: mesh.h:146
void indexReorder()
Definition: mesh.cpp:48
Eigen::Vector3d l
Definition: mesh.h:192
bool isInMagList(std::vector< int > &idxMagList, Facette::Fac &f)
Definition: mesh.h:428
std::vector< int > magTet
Definition: mesh.h:335
std::vector< Eigen::Matrix< double, Nodes::DIM, Tetra::NPI > > extSpaceField
Definition: mesh.h:344
const Eigen::Vector3d getNode_u(const int i) const
Definition: mesh.h:149
void readMesh(Settings const &mySets)
Definition: read.cpp:12
int getNbFacs(void) const
Definition: mesh.h:140
Eigen::Vector3d c
Definition: mesh.h:189
mesh(Settings &mySets)
Definition: mesh.h:34
void set_node_zero_v(const int i)
Definition: mesh.h:165
void init_distrib(Settings const &mySets)
Definition: mesh.h:217
double max_angle() const
Definition: mesh.h:283
std::vector< Edge > edges
Definition: mesh.h:327
int getNbNodes(void) const
Definition: mesh.h:137
std::vector< Nodes::Node > node
Definition: mesh.h:349
bool isMagnetic(const Tetra::Tet &t)
Definition: mesh.h:319
double minNodes(const Nodes::index coord) const
Definition: mesh.h:382
std::vector< bool > magNode
Definition: mesh.h:332
std::vector< std::vector< int > > volumeRegions
Definition: mesh.h:359
bool isMagnetic(const Facette::Fac &f)
Definition: mesh.h:322
int getNodeIndex(const int i) const
Definition: mesh.h:316
double getProj_ep(const int i) const
Definition: mesh.h:155
std::vector< Tetra::Tet > tet
Definition: mesh.h:204
double maxNodes(const Nodes::index coord) const
Definition: mesh.h:388
int getNbTets(void) const
Definition: mesh.h:143
void set_node_u0(const int i, Eigen::Vector3d const &val)
Definition: mesh.h:161
void sortNodes(Nodes::index long_axis)
Definition: mesh.cpp:97
std::vector< Facette::Fac > fac
Definition: mesh.h:201
mesh(const mesh &)=delete
void setBasis(const double r)
Definition: mesh.h:171
void evolution(void)
Definition: mesh.h:182
std::vector< int > magFac
Definition: mesh.h:341
double totalMagVol
Definition: mesh.h:198
const Eigen::Vector3d getNode_v(const int i) const
Definition: mesh.h:152
std::vector< int > node_index
Definition: mesh.h:356
std::vector< Tetra::prm > & paramTetra
Definition: mesh.h:207
void updateNode(int i, double vp, double vq, const double dt)
Definition: mesh.h:178
double getProj_eq(const int i) const
Definition: mesh.h:158
double vol
Definition: mesh.h:195
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:310
Container for all the settings provided by the user, with conversions to/from YAML.
Definition: feellgoodSettings.h:73
int verbose
Definition: feellgoodSettings.h:139
mag_exprType getMagType() const
Definition: feellgoodSettings.h:272
Eigen::Vector3d getMagnetization(const Eigen::Ref< Eigen::Vector3d > p) const
Definition: feellgoodSettings.h:282
int idxPrm
Definition: element.h:47
std::vector< int > ind
Definition: element.h:44
contains namespace Facette header containing Fac class, and some constants and a less_than operator t...
many settings to give some parameters to the solver, boundary conditions for the problem,...
@ R4toR3
Definition: feellgoodSettings.h:46
@ POSITION_ONLY
M(x, y, z)
Definition: feellgoodSettings.h:29
std::pair< int, int > Edge
Definition: mesh.h:23
constexpr double a[N][NPI]
Definition: facette.h:55
index
Definition: node.h:34
header to define struct Node
Eigen::Vector3d p
Definition: node.h:62
dataNode d[NB_DATANODE]
Definition: node.h:70
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