60 std::string fallback_name =
"ClassNONE";
61 std::string input = rootXML.get(
"ClassName", fallback_name);
62 input = bitpit::utils::string::trim(input);
63 if(input ==
"mimmo.AABBox"){
90 std::swap(m_origin, x.m_origin);
91 std::swap(m_span, x.m_span);
92 std::swap(m_axes, x.m_axes);
93 std::swap(m_listgeo, x.m_listgeo);
94 std::swap(m_writeInfo, x.m_writeInfo);
160 std::vector<MimmoSharedPointer<MimmoObject> >
162 std::vector<MimmoSharedPointer<MimmoObject> > result;
165 result.push_back(pp.first);
177 for(
auto val : listgeo){
190 if (geo ==
nullptr) {
191 (*m_log)<<
"warning: "<<
m_name<<
" not valid Geometry pointer. Doing nothing"<<std::endl;
195 m_listgeo.insert(std::make_pair(geo, geo->getType()));
224 AABBox::plot(std::string directory, std::string filename,
int counter,
bool binary){
229 activeP[0] = - 0.5 *
m_span;
230 activeP[6] = 0.5 *
m_span;
232 activeP[1] = activeP[0]; activeP[1][0] +=
m_span[0];
233 activeP[3] = activeP[0]; activeP[3][1] +=
m_span[1];
234 activeP[2] = activeP[6]; activeP[2][2] += -1.0*
m_span[2];
236 activeP[7] = activeP[6]; activeP[7][0] += -1.0*
m_span[0];
237 activeP[5] = activeP[6]; activeP[5][1] += -1.0*
m_span[1];
238 activeP[4] = activeP[0]; activeP[4][2] +=
m_span[2];
242 for(
auto &val : activeP){
243 for(
int i=0; i<3; ++i){
244 temp[i] = dotProduct(val, inv[i]);
250 for(
int i=0; i<8; ++i) activeConn[0].push_back(i);
252 bitpit::VTKFormat codex = bitpit::VTKFormat::ASCII;
253 if(binary){codex=bitpit::VTKFormat::APPENDED;}
254 bitpit::VTKElementType elDM = bitpit::VTKElementType::HEXAHEDRON;
255 bitpit::VTKUnstructuredGrid vtk(directory, filename, elDM);
256 vtk.setGeomData( bitpit::VTKUnstructuredField::POINTS, activeP) ;
257 vtk.setGeomData( bitpit::VTKUnstructuredField::CONNECTIVITY, activeConn) ;
258 vtk.setDimensions(1, 8);
260 if(counter>=0){vtk.setCounter(counter);}
281 double normx1= norm2(
m_axes[0]);
282 double normx2= norm2(
m_axes[1]);
283 double tol = std::numeric_limits<double>::min();
284 if (normx1 > tol && normx2 > tol){
296 pmin.fill(std::numeric_limits<double>::max());
297 pmax.fill(-1.0*std::numeric_limits<double>::max());
301 for(
auto & vert: ptr->getVertices()){
303 for(
int i=0;i<3; ++i){
304 val = dotProduct(coord,
m_axes[i]);
305 pmin[i] = std::fmin(pmin[i], val);
306 pmax[i] = std::fmax(pmax[i], val);
312 MPI_Allreduce(MPI_IN_PLACE, pmin.data(), 3, MPI_DOUBLE, MPI_MIN, m_communicator);
313 MPI_Allreduce(MPI_IN_PLACE, pmax.data(), 3, MPI_DOUBLE, MPI_MAX, m_communicator);
319 double avg_span = 0.0;
320 for(
auto & val:
m_span) avg_span+=val;
324 val = std::fmax(val, 1.E-04*avg_span);
327 darray3E originLoc = 0.5*(pmin+pmax);
328 for(
int i=0; i<3; ++i){
329 m_origin[i] = dotProduct(originLoc, inv[i]);
338 out<<
"AABBox "<<std::to_string(
getId())<<
" info:"<<std::endl;
341 out<<
"Origin: "<<std::scientific<<
m_origin<<std::endl;
343 out<<
"Axis 0: "<<std::scientific<<
m_axes[0]<<std::endl;
344 out<<
"Axis 1: "<<std::scientific<<
m_axes[1]<<std::endl;
345 out<<
"Axis 2: "<<std::scientific<<
m_axes[2]<<std::endl;
347 out<<
"Span: "<<std::scientific<<
m_span<<std::endl;
361 std::string nameGrid =
m_name;
376 if(slotXML.hasOption(
"WriteInfo")){
377 std::string input = slotXML.get(
"WriteInfo");
378 input = bitpit::utils::string::trim(input);
381 std::stringstream ss(input);
387 if(slotXML.hasSection(
"Axes")){
389 const bitpit::Config::Section & axesXML = slotXML.getSection(
"Axes");
391 for(
int i=0; i<3; ++i){
396 if(axesXML.hasOption(
"axis0")){
397 std::string input = axesXML.get(
"axis0");
398 input = bitpit::utils::string::trim(input);
400 std::stringstream ss(input);
401 ss>>axes[0][0]>>axes[0][1]>>axes[0][2];
405 if(axesXML.hasOption(
"axis1")){
406 std::string input = axesXML.get(
"axis1");
407 input = bitpit::utils::string::trim(input);
409 std::stringstream ss(input);
410 ss>>axes[1][0]>>axes[1][1]>>axes[1][2];
414 if(axesXML.hasOption(
"axis2")){
415 std::string input = axesXML.get(
"axis2");
416 input = bitpit::utils::string::trim(input);
418 std::stringstream ss(input);
419 ss>>axes[2][0]>>axes[2][1]>>axes[2][2];
438 slotXML.set(
"WriteInfo", std::to_string((
int)
m_writeInfo));
441 bitpit::Config::Section & axesXML = slotXML.addSection(
"Axes");
443 for(
int i=0; i<3; ++i){
444 std::string name =
"axis"+std::to_string(i);
445 std::stringstream ss;
446 ss<<std::scientific<<axes[i][0]<<
'\t'<<axes[i][1]<<
'\t'<<axes[i][2];
447 axesXML.set(name, ss.str());
460 for(std::size_t i=0; i<3; ++i){
461 for(std::size_t j=0; j<3; ++j){
462 out[j][i] = mat[i][j];
476 double det = mat[0][0] * (mat[1][1]*mat[2][2] - mat[2][1]*mat[1][2]) -
477 mat[0][1] * (mat[1][0]*mat[2][2] - mat[2][0]*mat[1][2]) +
478 mat[0][2] * (mat[1][0]*mat[2][1] - mat[2][0]*mat[1][1]);
480 out[0][0] = (mat[1][1]*mat[2][2] - mat[2][1]*mat[1][2])/det;
481 out[0][1] = (mat[0][2]*mat[2][1] - mat[2][2]*mat[0][1])/det;
482 out[0][2] = (mat[0][1]*mat[1][2] - mat[1][1]*mat[0][2])/det;
483 out[1][0] = (mat[1][2]*mat[2][0] - mat[2][2]*mat[1][0])/det;
484 out[1][1] = (mat[0][0]*mat[2][2] - mat[2][0]*mat[0][2])/det;
485 out[1][2] = (mat[0][2]*mat[1][0] - mat[1][2]*mat[0][0])/det;
486 out[2][0] = (mat[1][0]*mat[2][1] - mat[2][0]*mat[1][1])/det;
487 out[2][1] = (mat[0][1]*mat[2][0] - mat[2][1]*mat[0][0])/det;
488 out[2][2] = (mat[0][0]*mat[1][1] - mat[1][0]*mat[0][1])/det;