24 #include "BendGeometry.hpp"
33 m_name =
"mimmo.BendGeometry";
34 m_degree.fill({{0,0,0}});
36 m_system = { 1.0 , 0.0 , 0.0 , 0.0, 1.0, 0.0 , 0.0 , 0.0 , 1.0 };
47 m_name =
"mimmo.BendGeometry";
48 m_degree.fill({{0,0,0}});
50 m_system = { 1.0 , 0.0 , 0.0 , 0.0, 1.0, 0.0 , 0.0 , 0.0 , 1.0 };
53 std::string fallback_name =
"ClassNONE";
54 std::string input = rootXML.get(
"ClassName", fallback_name);
55 input = bitpit::utils::string::trim(input);
56 if(input ==
"mimmo.BendGeometry"){
72 m_origin = other.m_origin;
73 m_system = other.m_system;
74 m_local = other.m_local;
75 m_filter = other.m_filter;
76 m_degree = other.m_degree;
77 m_coeffs = other.m_coeffs;
94 std::swap(m_origin, x.m_origin);
95 std::swap(m_system, x.m_system);
96 std::swap(m_local , x.m_local);
97 m_filter.swap(x.m_filter);
98 std::swap(m_degree, x.m_degree);
99 std::swap(m_coeffs, x.m_coeffs);
100 m_displ.swap(x.m_displ);
111 built = (built && createPortIn<umatrix33E, BendGeometry>(&m_degree,
M_BMATRIX));
113 built = (built && createPortIn<dmatrix33E, BendGeometry>(&m_system,
M_AXES));
114 built = (built && createPortIn<darray3E, BendGeometry>(&m_origin,
M_POINT));
168 for(
int i=0; i<3; ++i){
169 for(
int j=0; j<3; ++j){
183 m_degree[i][j] = degree;
184 m_coeffs[i][j].resize(degree+1, 0.0);
207 m_coeffs[i][j] = coeffs;
226 m_system[0] = axes[0];
227 m_system[1] = axes[1];
228 m_system[2] = axes[2];
250 (*m_log)<<
m_name +
" : nullptr pointer to linked geometry found"<<std::endl;
251 throw std::runtime_error(
m_name +
"nullptr pointer to linked geometry found");
261 for(
int i=0; i<3; ++i){
262 for(
int j=0; j<3; ++j){
263 m_coeffs[i][j].resize(m_degree[i][j]+1, 0.0);
272 for (
const auto & vertex :
m_geometry->getVertices()){
273 point = vertex.getCoords();
276 point = toLocalCoord(point);
280 for (
int j=0; j<3; j++){
281 for (
int z=0; z<3; z++){
282 if (m_degree[j][z] > 0){
283 for (
int k=0; k<(int)m_degree[j][z]+1; k++){
284 value[j] += pow(point[z],(
double)k)*m_coeffs[j][z][k]*m_filter[
ID];
291 point = toGlobalCoord(point);
292 value = point - point0;
294 m_displ.insert(
ID, value);
317 m_log->setPriority(bitpit::log::Verbosity::DEBUG);
318 (*m_log)<<
"Not valid filter found in "<<
m_name<<
". Proceeding with default unitary field"<<std::endl;
319 m_log->setPriority(bitpit::log::Verbosity::NORMAL);
325 for (
const auto & vertex :
getGeometry()->getVertices()){
326 m_filter.insert(vertex.getId(), 1.0);
336 BendGeometry::toLocalCoord(
darray3E point){
339 work = point - m_origin;
341 return matmul(m_system, work);
354 for(
int i =0; i<3; ++i){
359 work2 =
matmul(work, m_system);
362 return (work2 + m_origin);
374 for (std::size_t i = 0; i < 3; i++) {
376 for (std::size_t j = 0; j <3; j++) {
377 out[i] += vec[j]*mat[j][i];
393 for (std::size_t i = 0; i < 3; i++) {
395 for (std::size_t j = 0; j <3; j++) {
396 out[i] += vec[j]*mat[i][j];
417 if(slotXML.hasSection(
"DegreesMatrix")){
418 auto & subslot = slotXML.getSection(
"DegreesMatrix");
420 temp.fill({{0,0,0}});
422 if(subslot.hasOption(
"xDispl")){
423 input = subslot.get(
"xDispl");
424 std::stringstream ss(bitpit::utils::string::trim(input));
425 for(
int i=0; i<3; ++i) ss>>temp[0][i];
428 if(subslot.hasOption(
"yDispl")){
429 input = subslot.get(
"yDispl");
430 std::stringstream ss(bitpit::utils::string::trim(input));
431 for(int i=0; i<3; ++i) ss>>temp[1][i];
434 if(subslot.hasOption(
"zDispl")){
435 input = subslot.get(
"zDispl");
436 std::stringstream ss(bitpit::utils::string::trim(input));
437 for(int i=0; i<3; ++i) ss>>temp[2][i];
444 if(slotXML.hasSection(
"PolyCoefficients")){
445 auto & subslot = slotXML.getSection(
"PolyCoefficients");
446 dmat33Evec &temp = m_coeffs;
447 std::string rootPoly =
"Poly";
450 for (int k=0; k<9; ++k){
451 locPoly = rootPoly + std::to_string(k);
452 if(subslot.hasOption(locPoly)){
453 input = subslot.get(locPoly);
454 std::stringstream ss(bitpit::utils::string::trim(input));
457 for(double & val: temp[ik][jk]) ss>>val;
462 if(slotXML.hasOption(
"Origin")){
463 std::string input = slotXML.get(
"Origin");
464 input = bitpit::utils::string::trim(input);
465 darray3E temp = {{0.0,0.0,0.0}};
467 std::stringstream ss(input);
468 for(auto &val : temp) ss>>val;
473 if(slotXML.hasSection(
"RefSystem")){
474 const bitpit::Config::Section & rfXML = slotXML.getSection(
"RefSystem");
475 std::string rootAxis =
"axis";
478 temp[0].fill(0.0); temp[0][0] = 1.0;
479 temp[1].fill(0.0); temp[1][1] = 1.0;
480 temp[2].fill(0.0); temp[2][2] = 1.0;
481 for(int i=0; i<3; ++i){
482 axis = rootAxis + std::to_string(i);
483 std::string input = rfXML.get(axis);
484 input = bitpit::utils::string::trim(input);
486 std::stringstream ss(input);
487 for(auto &val : temp[i]) ss>>val;
500 BendGeometry::flushSectionXML(bitpit::Config::Section & slotXML, std::string name){
504 BaseManipulation::flushSectionXML(slotXML, name);
506 bitpit::Config::Section & degXML = slotXML.addSection(
"DegreesMatrix");
510 for(
auto & val: m_degree){
511 std::stringstream ss;
512 for(
auto & loc: val) ss<<loc<<
'\t';
513 d_str[counter] = ss.str();
517 degXML.set(
"xDispl", d_str[0]);
518 degXML.set(
"yDispl", d_str[1]);
519 degXML.set(
"zDispl", d_str[2]);
521 bitpit::Config::Section & polyXML = slotXML.addSection(
"PolyCoefficients");
522 std::string rootPoly =
"Poly";
524 for(
int i=0; i<3; i++){
525 for(
int j =0; j<3; j++){
526 if(m_coeffs[i][j].empty())
continue;
527 locPoly = rootPoly + std::to_string(
int(i*3+j));
528 std::stringstream ss;
529 for(
auto & loc: m_coeffs[i][j]) ss<<loc<<
'\t';
530 polyXML.set(locPoly, ss.str());
535 std::stringstream ss;
536 ss<<std::scientific<<getOrigin()[0]<<
'\t'<<getOrigin()[1]<<
'\t'<<getOrigin()[2];
537 slotXML.set(
"Origin", ss.str());
541 auto rs = getRefSystem();
542 bitpit::Config::Section & rsXML = slotXML.addSection(
"RefSystem");
543 std::string rootAxis =
"axis";
544 std::string localAxis;
546 for(
auto &axis : rs){
547 localAxis = rootAxis+std::to_string(counter);
548 std::stringstream ss;
549 ss<<std::scientific<<axis[0]<<
'\t'<<axis[1]<<
'\t'<<axis[2];
550 rsXML.set(localAxis, ss.str());