19 #ifdef LIBMESH_ENABLE_VSMOOTHER 40 #ifdef __INTEL_COMPILER 41 # pragma optimize ( "", off ) 54 _dim(
mesh.mesh_dimension()),
57 _miniterBC(miniterBC),
61 _generate_data(false),
65 _area_of_interest(nullptr)
72 std::vector<float> * adapt_data,
77 double percent_to_move) :
79 _percent_to_move(percent_to_move),
81 _adapt_data(adapt_data),
82 _dim(
mesh.mesh_dimension()),
85 _miniterBC(miniterBC),
89 _generate_data(false),
93 _area_of_interest(nullptr)
100 std::vector<float> * adapt_data,
105 double percent_to_move) :
107 _percent_to_move(percent_to_move),
109 _adapt_data(adapt_data),
110 _dim(
mesh.mesh_dimension()),
113 _miniterBC(miniterBC),
115 _adaptive_func(CELL),
117 _generate_data(false),
121 _area_of_interest(area_of_interest)
145 std::string metric_filename =
"smoother.metric";
146 if (gr == 0 && me > 1)
149 std::string grid_filename =
"smoother.grid";
175 int vms_err =
readgr(R, mask, cells, mcells, edges, hnodes);
178 _logfile <<
"Error reading input mesh file" << std::endl;
183 vms_err =
readmetr(metric_filename, H);
187 _logfile <<
"Error reading metric file" << std::endl;
191 std::vector<int> iter(4);
197 _logfile <<
"Starting Grid Optimization" << std::endl;
198 clock_t ticks1 = clock();
199 full_smooth(R, mask, cells, mcells, edges, hnodes, theta, iter, me, H, adp, gr);
200 clock_t ticks2 = clock();
208 <<
static_cast<double>(ticks2-ticks1)/static_cast<double>(CLOCKS_PER_SEC)
213 _logfile <<
"Saving Result" << std::endl;
234 double total_dist = 0.;
237 Node & node_ref = *node;
240 for (
unsigned int j=0; j<
_dim; j++)
242 double distance = R[i][j] - node_ref(j);
245 total_dist += Utility::pow<2>(distance);
250 libmesh_assert_greater_equal (total_dist, 0.);
270 std::vector<int> & mask,
272 std::vector<int> & mcells,
273 std::vector<int> & edges,
274 std::vector<int> & hnodes)
280 std::unordered_set<dof_id_type> boundary_node_ids =
286 std::unordered_map<dof_id_type, std::vector<const Elem *>> nodes_to_elem_map;
293 Node & node_ref = *node;
296 for (
unsigned int j=0; j<
_dim; j++)
297 R[i][j] = node_ref(j);
303 if (boundary_node_ids.count(i))
310 std::vector<const Node *> neighbors;
314 Real x = node_ref(0);
315 Real y = node_ref(1);
320 std::vector<Real> thetas;
323 for (
const auto & neighbor : neighbors)
327 theta = atan2((*neighbor)(1)-y, (*neighbor)(0)-x);
330 thetas.push_back(theta);
337 for (std::size_t a=0; a<thetas.size()-1; a++)
340 for (std::size_t b=a+1; b<thetas.size(); b++)
345 if (boundary_node_ids.count(neighbors[a]->id()) &&
346 boundary_node_ids.count(neighbors[b]->id()) &&
394 switch (elem->n_vertices())
398 for (
unsigned int k=0; k<elem->n_vertices(); k++)
399 cells[i][k] = elem->node_id(k);
401 num = elem->n_vertices();
405 cells[i][0] = elem->node_id(0);
406 cells[i][1] = elem->node_id(1);
407 cells[i][2] = elem->node_id(3);
408 cells[i][3] = elem->node_id(2);
413 libmesh_error_msg(
"Unknown number of vertices = " << elem->n_vertices());
419 switch (elem->n_vertices())
423 for (
unsigned int k=0; k<elem->n_vertices(); k++)
424 cells[i][k] = elem->node_id(k);
425 num = elem->n_vertices();
430 cells[i][0] = elem->node_id(0);
431 cells[i][1] = elem->node_id(1);
432 cells[i][2] = elem->node_id(3);
433 cells[i][3] = elem->node_id(2);
435 cells[i][4] = elem->node_id(4);
436 cells[i][5] = elem->node_id(5);
437 cells[i][6] = elem->node_id(7);
438 cells[i][7] = elem->node_id(6);
443 libmesh_error_msg(
"Unknown 3D element with = " << elem->n_vertices() <<
" vertices.");
448 for (
int j=num; j<static_cast<int>(cells[i].size()); j++)
460 std::map<dof_id_type, std::vector<dof_id_type>>::iterator
464 for (
int i=0; it!=
end; it++)
466 libMesh::out <<
"Parent 1: " << (it->second)[0] << std::endl;
467 libMesh::out <<
"Parent 2: " << (it->second)[1] << std::endl;
468 libMesh::out <<
"Hanging Node: " << it->first << std::endl << std::endl;
471 edges[2*i] = (it->second)[1];
474 edges[2*i+1] = (it->second)[0];
477 hnodes[i] = it->first;
493 std::ifstream infile(
name.c_str());
497 for (
unsigned j=0; j<
_dim; j++)
499 for (
unsigned k=0; k<
_dim; k++)
500 infile >> H[i][j][k];
503 std::getline(infile, dummy);
519 libmesh_assert_greater_equal ((*
_adapt_data)[i], 0.);
524 libmesh_assert_greater_equal (
min, 0.);
546 for (
int i=0; el!=end_el; el++)
551 Point centroid = (*el)->centroid();
557 if ((*aoe_el)->contains_point(centroid))
580 std::size_t m = adapt_data.size();
583 for (std::size_t i=0; i<m; i++)
584 if (adapt_data[i] != 0)
586 afun[j] = adapt_data[i];
605 return x1*(y2*z3 - y3*z2) + y1*(z2*x3 - z3*x2) + z1*(x2*y3 - x3*y2);
615 return x1*y2 - x2*y1;
623 const std::vector<double> & K,
631 sqrt3 = std::sqrt(3.),
632 sqrt6 = std::sqrt(6.);
669 U[0][0] = -3*(1-K[0]-K[1]*0.5)+(K[0]-0.5*K[1])+K[1];
670 U[0][1] = -(1-K[0]-K[1]*0.5)+(K[0]-0.5*K[1])*3-K[1];
674 U[0][5] = 4*(1-K[0]-K[1]*0.5)-4*(K[0]-0.5*K[1]);
676 U[1][0] = (1-K[2]-K[3]*0.5)*(-1.5)+(K[2]-0.5*K[3])*(0.5)+K[3]*(0.5);
677 U[1][1] = (1-K[2]-K[3]*0.5)*(0.5)+(K[2]-0.5*K[3])*(-1.5)+K[3]*(0.5);
678 U[1][2] = (1-K[2]-K[3]*0.5)*(-1)+(K[2]-0.5*K[3])*(-1)+K[3]*(3);
679 U[1][3] = (K[2]-0.5*K[3])*(4.)+K[3]*(-2.);
680 U[1][4] = (1-K[2]-K[3]*0.5)*(4.)+K[3]*(-2.);
681 U[1][5] = (1-K[2]-K[3]*0.5)*(-2.)+(K[2]-0.5*K[3])*(-2.);
684 libmesh_error_msg(
"Invalid nvert = " << nvert);
692 U[0][0] = -(1-K[0])*(1-K[1]);
693 U[0][1] = (1-K[0])*(1-K[1]);
694 U[0][2] = -K[0]*(1-K[1]);
695 U[0][3] = K[0]*(1-K[1]);
696 U[0][4] = -(1-K[0])*K[1];
697 U[0][5] = (1-K[0])*K[1];
698 U[0][6] = -K[0]*K[1];
701 U[1][0] = -(1-K[2])*(1-K[3]);
702 U[1][1] = -K[2]*(1-K[3]);
703 U[1][2] = (1-K[2])*(1-K[3]);
704 U[1][3] = K[2]*(1-K[3]);
705 U[1][4] = -(1-K[2])*K[3];
706 U[1][5] = -K[2]*K[3];
707 U[1][6] = (1-K[2])*K[3];
710 U[2][0] = -(1-K[4])*(1-K[5]);
711 U[2][1] = -K[4]*(1-K[5]);
712 U[2][2] = -(1-K[4])*K[5];
713 U[2][3] = -K[4]*K[5];
714 U[2][4] = (1-K[4])*(1-K[5]);
715 U[2][5] = K[4]*(1-K[5]);
716 U[2][6] = (1-K[4])*K[5];
755 U[1][0] = 0.5*(-1+K[1]);
756 U[1][1] = 0.5*(-1+K[1]);
762 U[2][0] = -1. + K[2] + 0.5*K[3];
763 U[2][1] = -K[2] + 0.5*K[3];
765 U[2][3] = 1 - K[2] - 0.5*K[3];
766 U[2][4] = K[2] - 0.5*K[3];
769 else if (nvert == 10)
772 U[0][0] = -3.*(1 - K[0] - 0.5*K[1] - K[2]/3.) + (K[0] - 0.5*K[1] - K[2]/3.) + (K[1] - K[2]/3.) + K[2];
773 U[0][1] = -1.*(1 - K[0] - 0.5*K[1] - K[2]/3.) + 3.*(K[0] - 0.5*K[1] - K[2]/3.) - (K[1] - K[2]/3.) - K[2];
776 U[0][4] = 4.*(K[1] - K[2]/3.);
777 U[0][5] = -4.*(K[1] - K[2]/3.);
778 U[0][6] = 4.*(1. - K[0] - 0.5*K[1] - K[2]/3.) - 4.*(K[0] - 0.5*K[1] - K[2]/3.);
783 U[1][0] = -1.5*(1. - K[3] - K[4]*0.5 - K[5]/3.) + 0.5*(K[3] - 0.5*K[4] - K[5]/3.) + 0.5*(K[4] - K[5]/3.) + 0.5*K[5];
784 U[1][1] = 0.5*(1. - K[3] - K[4]*0.5 - K[5]/3.) - 1.5*(K[3] - 0.5*K[4] - K[5]/3.) + 0.5*(K[4] - K[5]/3.) + 0.5*K[5];
785 U[1][2] = -1.*(1. - K[3] - K[4]*0.5 - K[5]/3.) - (K[3] - 0.5*K[4] - K[5]/3.) + 3.*(K[4] - K[5]/3.) - K[5];
787 U[1][4] = 4.*( K[3] - 0.5*K[4] - K[5]/3.) - 2.*(K[4] - K[5]/3.);
788 U[1][5] = 4.*(1. - K[3] - 0.5*K[4] - K[5]/3.) - 2.*(K[4] - K[5]/3.);
789 U[1][6] = -2.*(1. - K[3] - 0.5*K[4] - K[5]/3.) - 2.*(K[3] - 0.5*K[4] - K[5]/3.);
794 U[2][0] = -(1. - K[6] - 0.5*K[7] - K[8]/3.) + (K[6] - 0.5*K[7] - K[8]/3.)/3. + (K[7] - K[8]/3.)/3. + K[8]/3.;
795 U[2][1] = (1. - K[6] - 0.5*K[7] - K[8]/3.)/3. - (K[6] - 0.5*K[7] - K[8]/3.) + (K[7] - K[8]/3.)/3. + K[8]/3.;
796 U[2][2] = (1. - K[6] - 0.5*K[7] - K[8]/3.)/3. + (K[6] - 0.5*K[7] - K[8]/3.)/3. - (K[7] - K[8]/3.) + K[8]/3.;
797 U[2][3] = -(1. - K[6] - 0.5*K[7] - K[8]/3.) - (K[6] - 0.5*K[7] - K[8]/3.) - (K[7] - K[8]/3.) + 3.*K[8];
798 U[2][4] = -4.*(K[6] - K[7]*0.5 - K[8]/3.)/3. - 4.*(K[7] - K[8]/3.)/3.;
799 U[2][5] = -4.*(1. - K[6] - K[7]*0.5 - K[8]/3.)/3. - 4.*( K[7] - K[8]/3.)/3.;
800 U[2][6] = -4.*(1. - K[6] - K[7]*0.5 - K[8]/3.)/3. - 4.*(K[6] - 0.5*K[7] - K[8]/3.)/3.;
801 U[2][7] = 4.*(K[6] - K[7]*0.5 - K[8]/3.) - 4.*K[8]/3.;
802 U[2][8] = 4.*(K[7] - K[8]/3.) - 4.*K[8]/3.;
803 U[2][9] = 4.*(1. - K[6] - K[7]*0.5 - K[8]/3.) - 4.*K[8]/3.;
806 libmesh_error_msg(
"Invalid nvert = " << nvert);
814 for (
unsigned i=0; i<
_dim; i++)
815 for (
int j=0; j<nvert; j++)
818 for (
unsigned k=0; k<
_dim; k++)
819 Q[i][j] += H[k][i]*U[k][j];
831 std::vector<double> & afun,
845 while (cells[i][nvert] >= 0)
847 x += R[cells[i][nvert]][0];
848 y += R[cells[i][nvert]][1];
850 z += R[cells[i][nvert]][2];
855 afun[i] = 5.*(x+y+z);
864 for (
unsigned j=0; j<
_dim; j++)
868 afun[i] = 5*std::sin(R[i][0]);
877 const std::vector<int> & mask,
879 const std::vector<int> & mcells,
880 const std::vector<int> & edges,
881 const std::vector<int> & hnodes,
883 const std::vector<int> & iter,
902 std::vector<double> afun(afun_size);
904 std::vector<double> Gamma(
_n_cells);
916 if (mask[i] == 2 || mask[i] == 1)
922 _logfile <<
"# of Boundary Nodes=" << NBN << std::endl;
930 _logfile <<
"# of moving Boundary Nodes=" << NBN << std::endl;
935 if ((mask[i]==1) || (mask[i]==2))
943 double qmin =
minq(R, cells, mcells, me, H, vol, Vmin);
951 <<
" min volume = " << Vmin
955 double epsilon = 1.e-9;
956 double eps = qmin < 0 ? std::sqrt(epsilon*epsilon+0.004*qmin*qmin*vol*vol) : epsilon;
957 double emax =
maxE(R, cells, mcells, me, H, vol, eps, w, Gamma, qmin);
960 _logfile <<
" emax=" << emax << std::endl;
976 while (((qmin <= 0) || (counter < iter[0]) || (
std::abs(emax-Enm1) > 1e-3)) &&
980 libmesh_assert_less (counter, iter[1]);
984 if ((ii >= 0) && (ii % 2 == 0))
987 eps = std::sqrt(epsilon*epsilon + 0.004*qmin*qmin*vol*vol);
994 if ((qmin <= 0) || (counter < ii))
998 if ((ladp != 0) && (gr == 0))
1001 double Jk =
minJ(R, maskf, cells, mcells, eps, w, me, H, vol, edges, hnodes,
1002 msglev, Vmin, emax, qmin, ladp, afun);
1011 <<
", qmin*G/vol=" << qmin
1012 <<
", Vmin=" << Vmin
1013 <<
", emax=" << emax
1015 <<
", Enm1=" << Enm1
1023 for (
int counter=0; counter<iter[2]; counter++)
1026 if ((adp != 0) && (gr == 0))
1029 double Jk =
minJ_BC(R, mask, cells, mcells, eps, w, me, H, vol, msglev, Vmin, emax, qmin, adp, afun, NBN);
1032 _logfile <<
"NBC niter=" << counter
1033 <<
", qmin*G/vol=" << qmin
1034 <<
", Vmin=" << Vmin
1035 <<
", emax=" << emax
1042 for (
int j=0; j<iter[1]; j++)
1051 if ((adp != 0) && (gr == 0))
1054 Jk =
minJ(R, maskf, cells, mcells, eps, w, me, H, vol, edges, hnodes, msglev, Vmin, emax, qmin, adp, afun);
1057 _logfile <<
" Re-smooth: niter=" << j
1058 <<
", qmin*G/vol=" << qmin
1059 <<
", Vmin=" << Vmin
1060 <<
", emax=" << emax
1066 _logfile <<
"NBC smoothed niter=" << counter
1067 <<
", qmin*G/vol=" << qmin
1068 <<
", Vmin=" << Vmin
1069 <<
", emax=" << emax
1079 const std::vector<int> & mcells,
1085 std::vector<double> & Gamma,
1089 std::vector<double> K(9);
1096 if (mcells[ii] >= 0)
1103 if (cells[ii][3] == -1)
1106 basisA(Q, 3, K, H[ii], me);
1108 std::vector<double> a1(3), a2(3);
1109 for (
int k=0; k<2; k++)
1110 for (
int l=0; l<3; l++)
1112 a1[k] += Q[k][l]*R[cells[ii][l]][0];
1113 a2[k] += Q[k][l]*R[cells[ii][l]][1];
1116 double det =
jac2(a1[0], a1[1], a2[0], a2[1]);
1117 double tr = 0.5*(a1[0]*a1[0] + a2[0]*a2[0] + a1[1]*a1[1] + a2[1]*a2[1]);
1118 double chi = 0.5*(det+std::sqrt(det*det+epsilon*epsilon));
1119 E = (1-w)*tr/chi + 0.5*w*(v + det*det/v)/chi;
1127 else if (cells[ii][4] == -1)
1130 for (
int i=0; i<2; i++)
1133 for (
int j=0; j<2; j++)
1136 basisA(Q, 4, K, H[ii], me);
1138 std::vector<double> a1(3), a2(3);
1139 for (
int k=0; k<2; k++)
1140 for (
int l=0; l<4; l++)
1142 a1[k] += Q[k][l]*R[cells[ii][l]][0];
1143 a2[k] += Q[k][l]*R[cells[ii][l]][1];
1146 double det =
jac2(a1[0],a1[1],a2[0],a2[1]);
1147 double tr = 0.5*(a1[0]*a1[0] + a2[0]*a2[0] + a1[1]*a1[1] + a2[1]*a2[1]);
1148 double chi = 0.5*(det+std::sqrt(det*det+epsilon*epsilon));
1149 E += 0.25*((1-w)*tr/chi + 0.5*w*(v + det*det/v)/chi);
1162 for (
int i=0; i<3; i++)
1166 K[1] =
static_cast<double>(k);
1168 for (
int j=0; j<3; j++)
1172 K[3] =
static_cast<double>(k);
1174 basisA(Q, 6, K, H[ii], me);
1176 std::vector<double> a1(3), a2(3);
1177 for (
int k2=0; k2<2; k2++)
1178 for (
int l=0; l<6; l++)
1180 a1[k2] += Q[k2][l]*R[cells[ii][l]][0];
1181 a2[k2] += Q[k2][l]*R[cells[ii][l]][1];
1184 double det =
jac2(a1[0],a1[1],a2[0],a2[1]);
1185 double sigma = 1./24.;
1190 double tr = 0.5*(a1[0]*a1[0] + a2[0]*a2[0] + a1[1]*a1[1] + a2[1]*a2[1]);
1191 double chi = 0.5*(det + std::sqrt(det*det + epsilon*epsilon));
1192 E += sigma*((1-w)*tr/chi + 0.5*w*(v + det*det/v)/chi);
1205 if (cells[ii][4] == -1)
1208 basisA(Q, 4, K, H[ii], me);
1210 std::vector<double> a1(3), a2(3), a3(3);
1211 for (
int k=0; k<3; k++)
1212 for (
int l=0; l<4; l++)
1214 a1[k] += Q[k][l]*R[cells[ii][l]][0];
1215 a2[k] += Q[k][l]*R[cells[ii][l]][1];
1216 a3[k] += Q[k][l]*R[cells[ii][l]][2];
1219 double det =
jac3(a1[0], a1[1], a1[2],
1220 a2[0], a2[1], a2[2],
1221 a3[0], a3[1], a3[2]);
1223 for (
int k=0; k<3; k++)
1224 tr += (a1[k]*a1[k] + a2[k]*a2[k] + a3[k]*a3[k])/3.;
1226 double chi = 0.5*(det+std::sqrt(det*det+epsilon*epsilon));
1227 E = (1-w)*
pow(tr,1.5)/chi + 0.5*w*(v + det*det/v)/chi;
1235 else if (cells[ii][6] == -1)
1238 for (
int i=0; i<2; i++)
1241 for (
int j=0; j<2; j++)
1244 for (
int k=0; k<3; k++)
1246 K[2] = 0.5*
static_cast<double>(k);
1247 K[3] =
static_cast<double>(k % 2);
1248 basisA(Q, 6, K, H[ii], me);
1250 std::vector<double> a1(3), a2(3), a3(3);
1251 for (
int kk=0; kk<3; kk++)
1252 for (
int ll=0; ll<6; ll++)
1254 a1[kk] += Q[kk][ll]*R[cells[ii][ll]][0];
1255 a2[kk] += Q[kk][ll]*R[cells[ii][ll]][1];
1256 a3[kk] += Q[kk][ll]*R[cells[ii][ll]][2];
1259 double det =
jac3(a1[0], a1[1], a1[2],
1260 a2[0], a2[1], a2[2],
1261 a3[0], a3[1], a3[2]);
1263 for (
int kk=0; kk<3; kk++)
1264 tr += (a1[kk]*a1[kk] + a2[kk]*a2[kk] + a3[kk]*a3[kk])/3.;
1266 double chi = 0.5*(det+std::sqrt(det*det+epsilon*epsilon));
1267 E += ((1-w)*
pow(tr,1.5)/chi + 0.5*w*(v + det*det/v)/chi)/12.;
1277 else if (cells[ii][8] == -1)
1280 for (
int i=0; i<2; i++)
1283 for (
int j=0; j<2; j++)
1286 for (
int k=0; k<2; k++)
1289 for (
int l=0; l<2; l++)
1292 for (
int m=0; m<2; m++)
1295 for (
int nn=0; nn<2; nn++)
1298 basisA(Q, 8, K, H[ii], me);
1300 std::vector<double> a1(3), a2(3), a3(3);
1301 for (
int kk=0; kk<3; kk++)
1302 for (
int ll=0; ll<8; ll++)
1304 a1[kk] += Q[kk][ll]*R[cells[ii][ll]][0];
1305 a2[kk] += Q[kk][ll]*R[cells[ii][ll]][1];
1306 a3[kk] += Q[kk][ll]*R[cells[ii][ll]][2];
1309 double det =
jac3(a1[0], a1[1], a1[2],
1310 a2[0], a2[1], a2[2],
1311 a3[0], a3[1], a3[2]);
1314 if ((i==nn) && (j==l) && (k==m))
1317 if (((i==nn) && (j==l) && (k!=m)) ||
1318 ((i==nn) && (j!=l) && (k==m)) ||
1319 ((i!=nn) && (j==l) && (k==m)))
1322 if (((i==nn) && (j!=l) && (k!=m)) ||
1323 ((i!=nn) && (j!=l) && (k==m)) ||
1324 ((i!=nn) && (j==l) && (k!=m)))
1327 if ((i!=nn) && (j!=l) && (k!=m))
1331 for (
int kk=0; kk<3; kk++)
1332 tr += (a1[kk]*a1[kk] + a2[kk]*a2[kk] + a3[kk]*a3[kk])/3.;
1334 double chi = 0.5*(det+std::sqrt(det*det + epsilon*epsilon));
1335 E += ((1-w)*
pow(tr,1.5)/chi + 0.5*w*(v + det*det/v)/chi)*sigma;
1350 for (
int i=0; i<4; i++)
1352 for (
int j=0; j<4; j++)
1354 for (
int k=0; k<4; k++)
1434 basisA(Q, 10, K, H[ii], me);
1436 std::vector<double> a1(3), a2(3), a3(3);
1437 for (
int kk=0; kk<3; kk++)
1438 for (
int ll=0; ll<10; ll++)
1440 a1[kk] += Q[kk][ll]*R[cells[ii][ll]][0];
1441 a2[kk] += Q[kk][ll]*R[cells[ii][ll]][1];
1442 a3[kk] += Q[kk][ll]*R[cells[ii][ll]][2];
1445 double det =
jac3(a1[0], a1[1], a1[2],
1446 a2[0], a2[1], a2[2],
1447 a3[0], a3[1], a3[2]);
1450 if ((i==j) && (j==k))
1452 else if ((i==j) || (j==k) || (i==k))
1458 for (
int kk=0; kk<3; kk++)
1459 tr += (a1[kk]*a1[kk] + a2[kk]*a2[kk] + a3[kk]*a3[kk])/3.;
1461 double chi = 0.5*(det+std::sqrt(det*det+epsilon*epsilon));
1462 E += ((1-w)*
pow(tr,1.5)/chi + 0.5*w*(v+det*det/v)/chi)*sigma;
1486 const std::vector<int> & mcells,
1492 std::vector<double> K(9);
1496 double vmin = 1.e32;
1497 double gqmin = 1.e32;
1500 if (mcells[ii] >= 0)
1505 if (cells[ii][3] == -1)
1508 basisA(Q, 3, K, H[ii], me);
1510 std::vector<double> a1(3), a2(3);
1511 for (
int k=0; k<2; k++)
1512 for (
int l=0; l<3; l++)
1514 a1[k] += Q[k][l]*R[cells[ii][l]][0];
1515 a2[k] += Q[k][l]*R[cells[ii][l]][1];
1518 double det =
jac2(a1[0],a1[1],a2[0],a2[1]);
1527 else if (cells[ii][4] == -1)
1531 for (
int i=0; i<2; i++)
1534 for (
int j=0; j<2; j++)
1537 basisA(Q, 4, K, H[ii], me);
1539 std::vector<double> a1(3), a2(3);
1540 for (
int k=0; k<2; k++)
1541 for (
int l=0; l<4; l++)
1543 a1[k] += Q[k][l]*R[cells[ii][l]][0];
1544 a2[k] += Q[k][l]*R[cells[ii][l]][1];
1547 double det =
jac2(a1[0],a1[1],a2[0],a2[1]);
1562 for (
int i=0; i<3; i++)
1566 K[1] =
static_cast<double>(k);
1568 for (
int j=0; j<3; j++)
1572 K[3] =
static_cast<double>(k);
1573 basisA(Q, 6, K, H[ii], me);
1575 std::vector<double> a1(3), a2(3);
1576 for (
int k2=0; k2<2; k2++)
1577 for (
int l=0; l<6; l++)
1579 a1[k2] += Q[k2][l]*R[cells[ii][l]][0];
1580 a2[k2] += Q[k2][l]*R[cells[ii][l]][1];
1583 double det =
jac2(a1[0], a1[1], a2[0], a2[1]);
1587 double sigma = 1./24.;
1602 if (cells[ii][4] == -1)
1605 basisA(Q, 4, K, H[ii], me);
1607 std::vector<double> a1(3), a2(3), a3(3);
1608 for (
int k=0; k<3; k++)
1609 for (
int l=0; l<4; l++)
1611 a1[k] += Q[k][l]*R[cells[ii][l]][0];
1612 a2[k] += Q[k][l]*R[cells[ii][l]][1];
1613 a3[k] += Q[k][l]*R[cells[ii][l]][2];
1616 double det =
jac3(a1[0], a1[1], a1[2],
1617 a2[0], a2[1], a2[2],
1618 a3[0], a3[1], a3[2]);
1627 else if (cells[ii][6] == -1)
1631 for (
int i=0; i<2; i++)
1634 for (
int j=0; j<2; j++)
1638 for (
int k=0; k<3; k++)
1641 K[3] =
static_cast<double>(k%2);
1642 basisA(Q, 6, K, H[ii], me);
1644 std::vector<double> a1(3), a2(3), a3(3);
1645 for (
int kk=0; kk<3; kk++)
1646 for (
int ll=0; ll<6; ll++)
1648 a1[kk] += Q[kk][ll]*R[cells[ii][ll]][0];
1649 a2[kk] += Q[kk][ll]*R[cells[ii][ll]][1];
1650 a3[kk] += Q[kk][ll]*R[cells[ii][ll]][2];
1653 double det =
jac3(a1[0], a1[1], a1[2],
1654 a2[0], a2[1], a2[2],
1655 a3[0], a3[1], a3[2]);
1659 double sigma = 1./12.;
1668 else if (cells[ii][8] == -1)
1672 for (
int i=0; i<2; i++)
1675 for (
int j=0; j<2; j++)
1678 for (
int k=0; k<2; k++)
1681 for (
int l=0; l<2; l++)
1684 for (
int m=0; m<2; m++)
1687 for (
int nn=0; nn<2; nn++)
1690 basisA(Q, 8, K, H[ii], me);
1692 std::vector<double> a1(3), a2(3), a3(3);
1693 for (
int kk=0; kk<3; kk++)
1694 for (
int ll=0; ll<8; ll++)
1696 a1[kk] += Q[kk][ll]*R[cells[ii][ll]][0];
1697 a2[kk] += Q[kk][ll]*R[cells[ii][ll]][1];
1698 a3[kk] += Q[kk][ll]*R[cells[ii][ll]][2];
1701 double det =
jac3(a1[0], a1[1], a1[2],
1702 a2[0], a2[1], a2[2],
1703 a3[0], a3[1], a3[2]);
1710 if ((i==nn) && (j==l) && (k==m))
1713 if (((i==nn) && (j==l) && (k!=m)) ||
1714 ((i==nn) && (j!=l) && (k==m)) ||
1715 ((i!=nn) && (j==l) && (k==m)))
1718 if (((i==nn) && (j!=l) && (k!=m)) ||
1719 ((i!=nn) && (j!=l) && (k==m)) ||
1720 ((i!=nn) && (j==l) && (k!=m)))
1723 if ((i!=nn) && (j!=l) && (k!=m))
1742 for (
int i=0; i<4; i++)
1744 for (
int j=0; j<4; j++)
1746 for (
int k=0; k<4; k++)
1836 basisA(Q, 10, K, H[ii], me);
1838 std::vector<double> a1(3), a2(3), a3(3);
1839 for (
int kk=0; kk<3; kk++)
1840 for (
int ll=0; ll<10; ll++)
1842 a1[kk] += Q[kk][ll]*R[cells[ii][ll]][0];
1843 a2[kk] += Q[kk][ll]*R[cells[ii][ll]][1];
1844 a3[kk] += Q[kk][ll]*R[cells[ii][ll]][2];
1847 double det =
jac3(a1[0], a1[1], a1[2],
1848 a2[0], a2[1], a2[2],
1849 a3[0], a3[1], a3[2]);
1855 if ((i==j) && (j==k))
1858 else if ((i==j) || (j==k) || (i==k))
1876 vol = v/
static_cast<double>(
_n_cells);
1888 const std::vector<int> & mask,
1890 const std::vector<int> & mcells,
1896 const std::vector<int> & edges,
1897 const std::vector<int> & hnodes,
1903 const std::vector<double> & afun)
1938 double nonzero = 0.;
1947 while (cells[i][nvert] >= 0)
1951 for (
unsigned j=0; j<
_dim; j++)
1956 for (
int k=0; k<
std::abs(adp); k++)
1957 G[i][j] += afun[i*(-adp)+k];
1960 for (
unsigned index=0; index<
_dim; index++)
1963 for (
unsigned k=0; k<3*
_dim +
_dim%2; k++)
1967 for (
unsigned j=0; j<3*
_dim +
_dim%2; j++)
1974 double lVmin, lqmin;
1975 Jpr +=
localP(W, F, R, cells[i], mask, epsilon, w, nvert, H[i],
1976 me, vol, 0, lVmin, lqmin, adp, afun, G[i]);
1980 for (
unsigned index=0; index<
_dim; index++)
1981 for (
int j=0; j<nvert; j++)
1986 for (
unsigned index=0; index<
_dim; index++)
1988 for (
int l=0; l<nvert; l++)
1990 for (
int m=0; m<nvert; m++)
1992 if ((W[index][l][m] != 0) &&
1993 (cells[i][m] >= cells[i][l]))
1999 if (
A[cells[i][l] + index*
_n_nodes][sch] != 0)
2001 if (JA[cells[i][l] + index*
_n_nodes][sch] == static_cast<int>(cells[i][m] + index*
_n_nodes))
2003 A[cells[i][l] + index*
_n_nodes][sch] =
A[cells[i][l] + index*
_n_nodes][sch] + W[index][l][m];
2011 A[cells[i][l] + index*
_n_nodes][sch] = W[index][l][m];
2016 if (sch > columns-1)
2017 _logfile <<
"error: # of nonzero entries in the " 2019 <<
" row of Hessian =" 2027 b[cells[i][l] + index*
_n_nodes] = b[cells[i][l] + index*
_n_nodes] - F[index][l];
2036 double Tau_hn =
pow(vol, 1./static_cast<double>(
_dim))*1e-10;
2039 int ind_i = hnodes[i];
2040 int ind_j = edges[2*i];
2041 int ind_k = edges[2*i+1];
2043 for (
unsigned j=0; j<
_dim; j++)
2045 int g_i = int(R[ind_i][j] - 0.5*(R[ind_j][j]+R[ind_k][j]));
2046 Jpr += g_i*g_i/(2*Tau_hn);
2047 b[ind_i + j*
_n_nodes] -= g_i/Tau_hn;
2048 b[ind_j + j*
_n_nodes] += 0.5*g_i/Tau_hn;
2049 b[ind_k + j*
_n_nodes] += 0.5*g_i/Tau_hn;
2052 for (
int ind=0; ind<columns; ind++)
2054 if (JA[ind_i][ind] == ind_i)
2055 A[ind_i][ind] += 1./Tau_hn;
2064 if ((JA[ind_i][ind] == ind_j) ||
2065 (JA[ind_i][ind] == ind_k))
2066 A[ind_i][ind] -= 0.5/Tau_hn;
2077 if (JA[ind_j][ind] == ind_i)
2078 A[ind_j][ind] -= 0.5/Tau_hn;
2080 if (JA[ind_k][ind] == ind_i)
2081 A[ind_k][ind] -= 0.5/Tau_hn;
2097 if ((JA[ind_j][ind] == ind_j) ||
2098 (JA[ind_j][ind] == ind_k))
2099 A[ind_j][ind] += 0.25/Tau_hn;
2101 if ((JA[ind_k][ind] == ind_j) ||
2102 (JA[ind_k][ind] == ind_k))
2103 A[ind_k][ind] += 0.25/Tau_hn;
2116 A[ind_j+2*
_n_nodes][ind] += 0.25/Tau_hn;
2121 A[ind_k+2*
_n_nodes][ind] += 0.25/Tau_hn;
2127 nonzero += b[i]*b[i];
2132 for (
int j=columns-1; j>1; j--)
2134 for (
int k=0; k<j; k++)
2136 if (JA[i][k] > JA[i][k+1])
2139 JA[i][k] = JA[i][k+1];
2141 double tmp =
A[i][k];
2142 A[i][k] =
A[i][k+1];
2149 double eps = std::sqrt(vol)*1e-9;
2159 for (
int k=0; k<columns; k++)
2169 ia[i+1] = ia[i] + nz;
2174 int sch = (msglev >= 3) ? 1 : 0;
2176 solver(m, ia, ja, a, u, b, eps, 100, sch);
2182 for (
unsigned index=0; index<
_dim; index++)
2194 for (
unsigned j=0; j<
_dim; j++)
2196 _logfile <<
"P[" << i <<
"][" << j <<
"]=" << P[i][j];
2202 _logfile <<
"dJ=" << std::sqrt(nonzero) <<
" J0=" << Jpr << std::endl;
2213 while ((Jpr <= J) && (j > -30))
2220 for (
unsigned k=0; k<
_dim; k++)
2221 Rpr[i][k] = R[i][k] + tau*P[i][k];
2232 while (cells[i][nvert] >= 0)
2235 double lVmin, lqmin;
2236 double lemax =
localP(W, F, Rpr, cells[i], mask, epsilon, w, nvert, H[i], me, vol, 1, lVmin, lqmin, adp, afun, G[i]);
2251 int ind_i = hnodes[ii];
2252 int ind_j = edges[2*ii];
2253 int ind_k = edges[2*ii+1];
2254 for (
unsigned jj=0; jj<
_dim; jj++)
2256 int g_i = int(Rpr[ind_i][jj] - 0.5*(Rpr[ind_j][jj]+Rpr[ind_k][jj]));
2257 J += g_i*g_i/(2*Tau_hn);
2263 _logfile <<
"tau=" << tau <<
" J=" << J << std::endl;
2276 for (
unsigned i=0; i<
_n_nodes; i++)
2277 for (
unsigned k=0; k<
_dim; k++)
2278 Rpr[i][k] = R[i][k] + tau*0.5*P[i][k];
2289 while (cells[i][nvert] >= 0)
2292 double lVmin, lqmin;
2293 double lemax =
localP(W, F, Rpr, cells[i], mask, epsilon, w, nvert, H[i], me, vol, 1, lVmin, lqmin, adp, afun, G[i]);
2308 int ind_i = hnodes[ii];
2309 int ind_j = edges[2*ii];
2310 int ind_k = edges[2*ii+1];
2312 for (
unsigned jj=0; jj<
_dim; jj++)
2314 int g_i = int(Rpr[ind_i][jj] - 0.5*(Rpr[ind_j][jj] + Rpr[ind_k][jj]));
2315 J += g_i*g_i/(2*Tau_hn);
2342 for (
unsigned k=0; k<
_dim; k++)
2344 R[j2][k] = R[j2][k] + T*P[j2][k];
2345 nonzero += T*P[j2][k]*T*P[j2][k];
2349 _logfile <<
"tau=" << T <<
", J=" << J << std::endl;
2351 return std::sqrt(nonzero);
2360 const std::vector<int> & mask,
2362 const std::vector<int> & mcells,
2373 const std::vector<double> & afun,
2377 double tau = 0., J = 0., T, Jpr, L, lVmin, lqmin, gVmin = 0., gqmin = 0., gVmin0 = 0.,
2378 gqmin0 = 0., lemax, gemax = 0., gemax0 = 0.;
2381 std::vector<int> Bind(NCN);
2382 std::vector<double> lam(NCN);
2383 std::vector<double> hm(2*
_n_nodes);
2384 std::vector<double> Plam(NCN);
2387 std::vector<double> constr(4*NCN);
2399 const double eps = std::sqrt(vol)*1e-9;
2401 for (
int i=0; i<4*NCN; i++)
2414 for (
int I=0; I<NCN; I++)
2432 while (cells[l][nvert] >= 0)
2438 if (i == cells[l][0])
2440 if (mask[cells[l][1]] > 0)
2449 if (mask[cells[l][2]] > 0)
2459 if (i == cells[l][1])
2461 if (mask[cells[l][0]] > 0)
2470 if (mask[cells[l][2]] > 0)
2480 if (i == cells[l][2])
2482 if (mask[cells[l][1]] > 0)
2491 if (mask[cells[l][0]] > 0)
2503 if ((i == cells[l][0]) ||
2506 if (mask[cells[l][1]] > 0)
2515 if (mask[cells[l][2]] > 0)
2525 if ((i == cells[l][1]) ||
2528 if (mask[cells[l][0]] > 0)
2537 if (mask[cells[l][3]] > 0)
2549 if (i == cells[l][0])
2551 if (mask[cells[l][1]] > 0)
2560 if (mask[cells[l][2]] > 0)
2570 if (i == cells[l][1])
2572 if (mask[cells[l][0]] > 0)
2581 if (mask[cells[l][2]] > 0)
2591 if (i == cells[l][2])
2593 if (mask[cells[l][1]] > 0)
2602 if (mask[cells[l][0]] > 0)
2612 if (i == cells[l][3])
2618 if (i == cells[l][4])
2624 if (i == cells[l][5])
2632 libmesh_error_msg(
"Unrecognized nvert = " << nvert);
2637 double del1 = R[j][0] - R[i][0];
2638 double del2 = R[i][0] - R[k][0];
2645 constr[I*4+2] = R[i][0];
2646 constr[I*4+3] = R[i][1];
2650 del1 = R[j][1] - R[i][1];
2651 del2 = R[i][1] - R[k][1];
2657 constr[I*4+2] = R[i][0];
2658 constr[I*4+3] = R[i][1];
2663 (R[i][0]-R[j][0])*(R[k][1]-R[j][1]) -
2664 (R[k][0]-R[j][0])*(R[i][1]-R[j][1]);
2668 constr[I*4] = 1./(R[k][0]-R[j][0]);
2669 constr[I*4+1] = -1./(R[k][1]-R[j][1]);
2670 constr[I*4+2] = R[i][0];
2671 constr[I*4+3] = R[i][1];
2676 double x0 = ((R[k][1]-R[j][1])*(R[i][0]*R[i][0]-R[j][0]*R[j][0]+R[i][1]*R[i][1]-R[j][1]*R[j][1]) +
2677 (R[j][1]-R[i][1])*(R[k][0]*R[k][0]-R[j][0]*R[j][0]+R[k][1]*R[k][1]-R[j][1]*R[j][1]))/(2*J);
2678 double y0 = ((R[j][0]-R[k][0])*(R[i][0]*R[i][0]-R[j][0]*R[j][0]+R[i][1]*R[i][1]-R[j][1]*R[j][1]) +
2679 (R[i][0]-R[j][0])*(R[k][0]*R[k][0]-R[j][0]*R[j][0]+R[k][1]*R[k][1]-R[j][1]*R[j][1]))/(2*J);
2682 constr[I*4+2] = (R[i][0]-x0)*(R[i][0]-x0) + (R[i][1]-y0)*(R[i][1]-y0);
2694 for (
int i=0; i<NCN; i++)
2698 double nonzero = 0.;
2703 for (
int nz=0; nz<5; nz++)
2718 while (cells[i][nvert] >= 0)
2721 for (
int j=0; j<nvert; j++)
2725 for (
int k=0; k<
std::abs(adp); k++)
2726 G[i][j] += afun[i*(-adp) + k];
2729 for (
int index=0; index<2; index++)
2730 for (
int k=0; k<nvert; k++)
2733 for (
int j=0; j<nvert; j++)
2738 Jpr +=
localP(W, F, R, cells[i], mask, epsilon, w, nvert, H[i],
2739 me, vol, 0, lVmin, lqmin, adp, afun, G[i]);
2743 for (
unsigned index=0; index<2; index++)
2744 for (
int j=0; j<nvert; j++)
2748 for (
unsigned index=0; index<2; index++)
2749 for (
int l=0; l<nvert; l++)
2752 hm[cells[i][l] + index*
_n_nodes] += W[index][l][l];
2753 b[cells[i][l] + index*
_n_nodes] -= F[index][l];
2759 nonzero += b[i]*b[i];
2762 for (
int I=0; I<NCN; I++)
2770 if (constr[4*I+3] < 0.5/eps)
2774 g = (R[i][0]-constr[4*I+2])*constr[4*I] + (R[i][1]-constr[4*I+3])*constr[4*I+1];
2778 Bx = 2*(R[i][0] - constr[4*I]);
2779 By = 2*(R[i][1] - constr[4*I+1]);
2783 (R[i][0] - constr[4*I])*(R[i][0]-constr[4*I]) +
2784 (R[i][1] - constr[4*I+1])*(R[i][1]-constr[4*I+1]) - constr[4*I+2];
2789 double a = Bx*Bx/hm[i] + By*By/hm[i+
_n_nodes];
2794 _logfile <<
"error: B^TH-1B is degenerate" << std::endl;
2804 P[i][0] = b[i]/hm[i];
2810 for (
unsigned j=0; j<2; j++)
2811 if ((
std::abs(P[i][j]) < eps) || (mask[i] == 1))
2818 for (
unsigned j=0; j<2; j++)
2820 _logfile <<
"P[" << i <<
"][" << j <<
"]=" << P[i][j] <<
" ";
2825 _logfile <<
"dJ=" << std::sqrt(nonzero) <<
" L0=" << Jpr << std::endl;
2830 while ((Jpr <= L) && (j > -30))
2835 for (
unsigned k=0; k<2; k++)
2836 Rpr[i][k] = R[i][k] + tau*P[i][k];
2846 while (cells[i][nvert] >= 0)
2849 lemax =
localP(W, F, Rpr, cells[i], mask, epsilon, w, nvert, H[i], me, vol, 1, lVmin,
2850 lqmin, adp, afun, G[i]);
2866 for (
int I=0; I<NCN; I++)
2871 if (constr[4*I+3] < 0.5/eps)
2872 g = (Rpr[i][0] - constr[4*I+2])*constr[4*I] + (Rpr[i][1]-constr[4*I+3])*constr[4*I+1];
2875 g = (Rpr[i][0]-constr[4*I])*(Rpr[i][0]-constr[4*I]) +
2876 (Rpr[i][1]-constr[4*I+1])*(Rpr[i][1]-constr[4*I+1]) - constr[4*I+2];
2878 L += (lam[I] + tau*Plam[I])*g;
2883 _logfile <<
" tau=" << tau <<
" J=" << J << std::endl;
2893 for (
unsigned k=0; k<2; k++)
2894 Rpr[i][k] = R[i][k] + tau*0.5*P[i][k];
2905 while (cells[i][nvert] >= 0)
2908 lemax =
localP(W, F, Rpr, cells[i], mask, epsilon, w, nvert, H[i], me, vol, 1, lVmin,
2909 lqmin, adp, afun, G[i]);
2925 for (
int I=0; I<NCN; I++)
2930 if (constr[4*I+3] < 0.5/eps)
2931 g = (Rpr[i][0]-constr[4*I+2])*constr[4*I] + (Rpr[i][1]-constr[4*I+3])*constr[4*I+1];
2934 g = (Rpr[i][0]-constr[4*I])*(Rpr[i][0]-constr[4*I]) +
2935 (Rpr[i][1]-constr[4*I+1])*(Rpr[i][1]-constr[4*I+1]) - constr[4*I+2];
2937 L += (lam[I] + tau*0.5*Plam[I])*g;
2962 for (
unsigned k=0; k<2; k++)
2963 R[i][k] += T*P[i][k];
2965 for (
int i=0; i<NCN; i++)
2966 lam[i] += T*Plam[i];
2971 _logfile <<
"tau=" << T <<
", J=" << J <<
", L=" << L << std::endl;
2973 return std::sqrt(nonzero);
2982 const std::vector<int> & cell_in,
2983 const std::vector<int> & mask,
2994 const std::vector<double> & afun,
2995 std::vector<double> & Gloc)
2998 std::vector<double> K(9);
3006 avertex(afun, Gloc, R, cell_in, nvert, adp);
3009 for (
unsigned i=0; i<
_dim; i++)
3029 fun +=
vertex(W, F, R, cell_in, epsilon, w, nvert, K, H, me, vol, f, lqmin, adp, Gloc, sigma);
3037 for (
unsigned i=0; i<2; i++)
3040 for (
unsigned j=0; j<2; j++)
3044 fun +=
vertex(W, F, R, cell_in, epsilon, w, nvert, K, H, me,
3045 vol, f, lqmin, adp, Gloc, sigma);
3055 for (
unsigned i=0; i<3; i++)
3059 K[1] =
static_cast<double>(k);
3061 for (
unsigned j=0; j<3; j++)
3065 K[3] =
static_cast<double>(k);
3071 fun +=
vertex(W, F, R, cell_in, epsilon, w, nvert, K, H, me,
3072 vol, f, lqmin, adp, Gloc, sigma);
3087 fun +=
vertex(W, F, R, cell_in, epsilon, w, nvert, K, H, me,
3088 vol, f, lqmin, adp, Gloc, sigma);
3096 for (
unsigned i=0; i<2; i++)
3099 for (
unsigned j=0; j<2; j++)
3102 for (
unsigned k=0; k<3; k++)
3104 K[2] = 0.5*
static_cast<double>(k);
3105 K[3] =
static_cast<double>(k % 2);
3107 fun +=
vertex(W, F, R, cell_in, epsilon, w, nvert, K, H, me,
3108 vol, f, lqmin, adp, Gloc, sigma);
3119 for (
unsigned i=0; i<2; i++)
3122 for (
unsigned j=0; j<2; j++)
3125 for (
unsigned k=0; k<2; k++)
3128 for (
unsigned l=0; l<2; l++)
3131 for (
unsigned m=0; m<2; m++)
3134 for (
unsigned nn=0; nn<2; nn++)
3138 if ((i==nn) && (j==l) && (k==m))
3141 if (((i==nn) && (j==l) && (k!=m)) ||
3142 ((i==nn) && (j!=l) && (k==m)) ||
3143 ((i!=nn) && (j==l) && (k==m)))
3146 if (((i==nn) && (j!=l) && (k!=m)) ||
3147 ((i!=nn) && (j!=l) && (k==m)) ||
3148 ((i!=nn) && (j==l) && (k!=m)))
3151 if ((i!=nn) && (j!=l) && (k!=m))
3154 fun +=
vertex(W, F, R, cell_in, epsilon, w, nvert, K, H, me,
3155 vol, f, lqmin, adp, Gloc, sigma);
3170 for (
unsigned i=0; i<4; i++)
3172 for (
unsigned j=0; j<4; j++)
3174 for (
unsigned k=0; k<4; k++)
3266 if ((i==j) && (j==k))
3269 else if ((i==j) || (j==k) || (i==k))
3275 fun +=
vertex(W, F, R, cell_in, epsilon, w, nvert, K, H, me,
3276 vol, f, lqmin, adp, Gloc, sigma);
3288 for (
int ii=0; ii<nvert; ii++)
3290 if (mask[cell_in[ii]] == 1)
3292 for (
unsigned kk=0; kk<
_dim; kk++)
3294 for (
int jj=0; jj<nvert; jj++)
3318 std::vector<double> & G,
3320 const std::vector<int> & cell_in,
3324 std::vector<double> a1(3), a2(3), a3(3), qu(3), K(8);
3327 for (
int i=0; i<8; i++)
3330 basisA(Q, nvert, K, Q, 1);
3332 for (
unsigned i=0; i<
_dim; i++)
3333 for (
int j=0; j<nvert; j++)
3335 a1[i] += Q[i][j]*R[cell_in[j]][0];
3336 a2[i] += Q[i][j]*R[cell_in[j]][1];
3338 a3[i] += Q[i][j]*R[cell_in[j]][2];
3340 qu[i] += Q[i][j]*afun[cell_in[j]];
3346 det =
jac2(a1[0], a1[1],
3349 det =
jac3(a1[0], a1[1], a1[2],
3350 a2[0], a2[1], a2[2],
3351 a3[0], a3[1], a3[2]);
3360 double df0 =
jac2(qu[0], qu[1], a2[0], a2[1])/det;
3361 double df1 =
jac2(a1[0], a1[1], qu[0], qu[1])/det;
3362 g = (1. + df0*df0 + df1*df1);
3367 G[0] = 1. + df0*df0;
3368 G[1] = 1. + df1*df1;
3372 for (
unsigned i=0; i<
_dim; i++)
3378 double df0 = (qu[0]*(a2[1]*a3[2]-a2[2]*a3[1]) + qu[1]*(a2[2]*a3[0]-a2[0]*a3[2]) + qu[2]*(a2[0]*a3[1]-a2[1]*a3[0]))/det;
3379 double df1 = (qu[0]*(a3[1]*a1[2]-a3[2]*a1[1]) + qu[1]*(a3[2]*a1[0]-a3[0]*a1[2]) + qu[2]*(a3[0]*a1[1]-a3[1]*a1[0]))/det;
3380 double df2 = (qu[0]*(a1[1]*a2[2]-a1[2]*a2[1]) + qu[1]*(a1[2]*a2[0]-a1[0]*a2[2]) + qu[2]*(a1[0]*a2[1]-a1[1]*a2[0]))/det;
3381 g = 1. + df0*df0 + df1*df1 + df2*df2;
3385 G[0] = 1. + df0*df0;
3386 G[1] = 1. + df1*df1;
3387 G[2] = 1. + df2*df2;
3391 for (
unsigned i=0; i<
_dim; i++)
3399 for (
unsigned i=0; i<
_dim; i++)
3412 const std::vector<int> & cell_in,
3416 const std::vector<double> & K,
3423 const std::vector<double> & g,
3428 basisA(Q, nvert, K, H, me);
3430 std::vector<double> a1(3), a2(3), a3(3);
3431 for (
unsigned i=0; i<
_dim; i++)
3432 for (
int j=0; j<nvert; j++)
3434 a1[i] += Q[i][j]*R[cell_in[j]][0];
3435 a2[i] += Q[i][j]*R[cell_in[j]][1];
3437 a3[i] += Q[i][j]*R[cell_in[j]][2];
3447 for (
unsigned i=0; i<
_dim; i++)
3449 a1[i] *= std::sqrt(g[0]);
3450 a2[i] *= std::sqrt(g[1]);
3452 a3[i] *= std::sqrt(g[2]);
3461 std::vector<double> av1(3), av2(3), av3(3);
3469 det =
jac2(a1[0], a1[1], a2[0], a2[1]);
3470 for (
int i=0; i<2; i++)
3471 tr += 0.5*(a1[i]*a1[i] + a2[i]*a2[i]);
3473 phit = (1-w)*tr + w*0.5*(vol/G + det*det*G/vol);
3478 av1[0] = a2[1]*a3[2] - a2[2]*a3[1];
3479 av1[1] = a2[2]*a3[0] - a2[0]*a3[2];
3480 av1[2] = a2[0]*a3[1] - a2[1]*a3[0];
3482 av2[0] = a3[1]*a1[2] - a3[2]*a1[1];
3483 av2[1] = a3[2]*a1[0] - a3[0]*a1[2];
3484 av2[2] = a3[0]*a1[1] - a3[1]*a1[0];
3486 av3[0] = a1[1]*a2[2] - a1[2]*a2[1];
3487 av3[1] = a1[2]*a2[0] - a1[0]*a2[2];
3488 av3[2] = a1[0]*a2[1] - a1[1]*a2[0];
3490 det =
jac3(a1[0], a1[1], a1[2],
3491 a2[0], a2[1], a2[2],
3492 a3[0], a3[1], a3[2]);
3494 for (
int i=0; i<3; i++)
3495 tr += (1./3.)*(a1[i]*a1[i] + a2[i]*a2[i] + a3[i]*a3[i]);
3497 phit = (1-w)*
pow(tr,1.5) + w*0.5*(vol/G + det*det*G/vol);
3500 double dchi = 0.5 + det*0.5/std::sqrt(epsilon*epsilon + det*det);
3501 double chi = 0.5*(det + std::sqrt(epsilon*epsilon + det*det));
3502 double fet = (chi != 0.) ? phit/chi : 1.e32;
3517 for (
int i=0; i<2; i++)
3519 dphi[0][i] = (1-w)*a1[i] + w*G*det*av1[i]/vol;
3520 dphi[1][i] = (1-w)*a2[i] + w*G*det*av2[i]/vol;
3523 for (
int i=0; i<2; i++)
3524 for (
int j=0; j<2; j++)
3526 d2phi[0][i][j] = w*G*av1[i]*av1[j]/vol;
3527 d2phi[1][i][j] = w*G*av2[i]*av2[j]/vol;
3530 for (
int k=0; k<2; k++)
3531 d2phi[k][i][j] += 1.-w;
3534 for (
int i=0; i<2; i++)
3536 dfe[0][i] = (dphi[0][i] - fet*dchi*av1[i])/chi;
3537 dfe[1][i] = (dphi[1][i] - fet*dchi*av2[i])/chi;
3540 for (
int i=0; i<2; i++)
3541 for (
int j=0; j<2; j++)
3543 P[0][i][j] = (d2phi[0][i][j] - dchi*(av1[i]*dfe[0][j] + dfe[0][i]*av1[j]))/chi;
3544 P[1][i][j] = (d2phi[1][i][j] - dchi*(av2[i]*dfe[1][j] + dfe[1][i]*av2[j]))/chi;
3550 for (
int i=0; i<3; i++)
3552 dphi[0][i] = (1-w)*std::sqrt(tr)*a1[i] + w*G*det*av1[i]/vol;
3553 dphi[1][i] = (1-w)*std::sqrt(tr)*a2[i] + w*G*det*av2[i]/vol;
3554 dphi[2][i] = (1-w)*std::sqrt(tr)*a3[i] + w*G*det*av3[i]/vol;
3557 for (
int i=0; i<3; i++)
3561 d2phi[0][i][i] = (1-w)/(3.*std::sqrt(tr))*a1[i]*a1[i] + w*G*av1[i]*av1[i]/vol;
3562 d2phi[1][i][i] = (1-w)/(3.*std::sqrt(tr))*a2[i]*a2[i] + w*G*av2[i]*av2[i]/vol;
3563 d2phi[2][i][i] = (1-w)/(3.*std::sqrt(tr))*a3[i]*a3[i] + w*G*av3[i]*av3[i]/vol;
3567 for (
int k=0; k<3; k++)
3568 d2phi[k][i][i] = 0.;
3571 for (
int k=0; k<3; k++)
3572 d2phi[k][i][i] += (1-w)*std::sqrt(tr);
3575 const double con = 100.;
3577 for (
int i=0; i<3; i++)
3579 dfe[0][i] = (dphi[0][i] - fet*dchi*av1[i] + con*epsilon*a1[i])/chi;
3580 dfe[1][i] = (dphi[1][i] - fet*dchi*av2[i] + con*epsilon*a2[i])/chi;
3581 dfe[2][i] = (dphi[2][i] - fet*dchi*av3[i] + con*epsilon*a3[i])/chi;
3584 for (
int i=0; i<3; i++)
3586 P[0][i][i] = (d2phi[0][i][i] - dchi*(av1[i]*dfe[0][i] + dfe[0][i]*av1[i]) + con*epsilon)/chi;
3587 P[1][i][i] = (d2phi[1][i][i] - dchi*(av2[i]*dfe[1][i] + dfe[1][i]*av2[i]) + con*epsilon)/chi;
3588 P[2][i][i] = (d2phi[2][i][i] - dchi*(av3[i]*dfe[2][i] + dfe[2][i]*av3[i]) + con*epsilon)/chi;
3591 for (
int k=0; k<3; k++)
3592 for (
int i=0; i<3; i++)
3593 for (
int j=0; j<3; j++)
3601 for (
unsigned i1=0; i1<
_dim; i1++)
3603 for (
unsigned i=0; i<
_dim; i++)
3604 for (
int j=0; j<nvert; j++)
3605 for (
unsigned k=0; k<
_dim; k++)
3606 gpr[i][j] += P[i1][i][k]*Q[k][j];
3608 for (
int i=0; i<nvert; i++)
3609 for (
int j=0; j<nvert; j++)
3610 for (
unsigned k=0; k<
_dim; k++)
3611 W[i1][i][j] += Q[k][i]*gpr[k][j]*sigma;
3613 for (
int i=0; i<nvert; i++)
3614 for (
int k=0; k<2; k++)
3615 F[i1][i] += Q[k][i]*dfe[i1][k]*sigma;
3628 const std::vector<int> & ia,
3629 const std::vector<int> & ja,
3630 const std::vector<double> & a,
3631 std::vector<double> & x,
3632 const std::vector<double> & b,
3637 _logfile <<
"Beginning Solve " << n << std::endl;
3640 int info =
pcg_par_check(n, ia, ja, a, eps, maxite, msglev);
3645 std::vector<double> u(n);
3646 for (
int i=0; i<n; i++)
3650 std::vector<double> r(n), p(n), z(n);
3651 info =
pcg_ic0(n, ia, ja, a, u, x, b, r, p, z, eps, maxite, msglev);
3656 _logfile <<
"Finished Solve " << n << std::endl;
3665 const std::vector<int> & ia,
3666 const std::vector<int> & ja,
3667 const std::vector<double> & a,
3677 _logfile <<
"sol_pcg: incorrect input parameter: n =" << n << std::endl;
3684 _logfile <<
"sol_pcg: incorrect input parameter: ia(1) =" << ia[0] << std::endl;
3690 if (ia[i+1] < ia[i])
3693 _logfile <<
"sol_pcg: incorrect input parameter: i =" 3697 <<
" must be <= a(i+1) =" 3706 if (ja[ia[i]] != (i+1))
3709 _logfile <<
"sol_pcg: incorrect input parameter: i =" 3713 <<
" ; absence of diagonal entry; k =" 3715 <<
" ; the value ja(k) =" 3717 <<
" must be equal to i" 3724 for (k=ia[i]; k<ia[i+1]; k++)
3727 if ((j<(i+1)) || (j>n))
3730 _logfile <<
"sol_pcg: incorrect input parameter: i =" 3738 <<
" ; the value ja(k) =" 3740 <<
" is out of range" 3748 _logfile <<
"sol_pcg: incorrect input parameter: i =" 3756 <<
" ; the value ja(k) =" 3758 <<
" must be less than ja(k+1) =" 3773 _logfile <<
"sol_pcg: incorrect input parameter: i =" 3777 <<
" ; the diagonal entry a(ia(i)) =" 3789 _logfile <<
"sol_pcg: incorrect input parameter: eps =" << eps << std::endl;
3796 _logfile <<
"sol_pcg: incorrect input parameter: maxite =" << maxite << std::endl;
3807 const std::vector<int> & ia,
3808 const std::vector<int> & ja,
3809 const std::vector<double> & a,
3810 const std::vector<double> & u,
3811 std::vector<double> & x,
3812 const std::vector<double> & b,
3813 std::vector<double> & r,
3814 std::vector<double> & p,
3815 std::vector<double> & z,
3829 for (i=0; i<=maxite; i++)
3835 for (
int ii=0; ii<n; ii++)
3838 for (
int ii=0; ii<n; ii++)
3840 z[ii] += a[ia[ii]]*p[ii];
3842 for (
int j=ia[ii]+1; j<ia[ii+1]; j++)
3844 z[ii] += a[j]*p[ja[j]-1];
3845 z[ja[j]-1] += a[j]*p[ii];
3850 for (
int k=0; k<n; k++)
3856 for (
int k=0; k<n; k++)
3859 double alpha = rhr/pap;
3860 for (
int k=0; k<n; k++)
3869 for (
int ii=0; ii<n; ii++)
3870 z[ii] = r[ii]*u[ii];
3877 for (
int k=0; k<n; k++)
3892 << std::sqrt(rhr/rhr0)
3894 << std::sqrt(rr/rr0)
3897 if (rr <= eps*eps*rr0)
3905 double beta = rhr/rhrold;
3906 for (
int k=0; k<n; k++)
3907 p[k] = z[k] + p[k]*beta;
3927 for (
int i=0; i<n; i++)
3933 const double x = 1./
static_cast<double>(n1-1);
3935 std::ofstream outfile(grid);
3937 outfile << n <<
"\n" << N <<
"\n" << ncells <<
"\n0\n" << std::endl;
3939 for (
int i=0; i<N; i++)
3944 for (
int j=0; j<n; j++)
3947 if ((ii == 0) || (ii == n1-1))
3950 outfile << static_cast<double>(ii)*x <<
" ";
3953 outfile << mask << std::endl;
3956 for (
int i=0; i<ncells; i++)
3966 outfile << ii+n1*jj <<
" " 3967 << ii+1+jj*n1 <<
" " 3968 << ii+(jj+1)*n1 <<
" " 3969 << ii+1+(jj+1)*n1 <<
" ";
3972 outfile << ii+n1*jj+n1*n1*kk <<
" " 3973 << ii+1+jj*n1+n1*n1*kk <<
" " 3974 << ii+(jj+1)*n1+n1*n1*kk <<
" " 3975 << ii+1+(jj+1)*n1+n1*n1*kk <<
" " 3976 << ii+n1*jj+n1*n1*(kk+1) <<
" " 3977 << ii+1+jj*n1+n1*n1*(kk+1) <<
" " 3978 << ii+(jj+1)*n1+n1*n1*(kk+1) <<
" " 3979 << ii+1+(jj+1)*n1+n1*n1*(kk+1) <<
" ";
3981 outfile <<
"-1 -1 0 \n";
3992 double det, g1, g2, g3, det_o, g1_o, g2_o, g3_o, eps=1e-3;
3994 std::vector<double> K(9);
4008 readgr(R, mask, cells, mcells, mcells, mcells);
4011 std::ofstream metric_file(metr.c_str());
4012 if (!metric_file.good())
4013 libmesh_error_msg(
"Error opening metric output file.");
4016 metric_file << std::scientific << std::setprecision(6);
4023 for (
unsigned i=0; i<
_n_cells; i++)
4027 while (cells[i][nvert] >= 0)
4039 for (
int k=0; k<2; k++)
4040 for (
int l=0; l<3; l++)
4042 a1(k) += Q[k][l]*R[cells[i][l]][0];
4043 a2(k) += Q[k][l]*R[cells[i][l]][1];
4046 det =
jac2(a1(0), a1(1), a2(0), a2(1));
4047 g1 = std::sqrt(a1(0)*a1(0) + a2(0)*a2(0));
4048 g2 = std::sqrt(a1(1)*a1(1) + a2(1)*a2(1));
4051 if ((
std::abs(det) < eps*eps*det_o) || (det < 0))
4054 if ((
std::abs(g1) < eps*g1_o) || (g1<0))
4057 if ((
std::abs(g2) < eps*g2_o) || (g2<0))
4062 metric_file << 1./std::sqrt(det)
4063 <<
" 0.000000e+00 \n0.000000e+00 " 4064 << 1./std::sqrt(det)
4068 metric_file << 1./g1
4069 <<
" 0.000000e+00 \n0.000000e+00 " 4084 const unsigned node_indices[4] = {0, 1, 3, 2};
4085 const unsigned first_neighbor_indices[4] = {1, 3, 2, 0};
4086 const unsigned second_neighbor_indices[4] = {2, 0, 1, 3};
4090 for (
unsigned ni=0; ni<4; ++ni)
4093 node_index = node_indices[ni],
4094 first_neighbor_index = first_neighbor_indices[ni],
4095 second_neighbor_index = second_neighbor_indices[ni];
4098 node_x = R[cells[i][node_index]][0],
4099 node_y = R[cells[i][node_index]][1],
4100 first_neighbor_x = R[cells[i][first_neighbor_index]][0],
4101 first_neighbor_y = R[cells[i][first_neighbor_index]][1],
4102 second_neighbor_x = R[cells[i][second_neighbor_index]][0],
4103 second_neighbor_y = R[cells[i][second_neighbor_index]][1];
4107 Point a1(first_neighbor_x - node_x,
4108 second_neighbor_x - node_x);
4111 Point a2(first_neighbor_y - node_y,
4112 second_neighbor_y - node_y);
4114 det =
jac2(a1(0), a1(1), a2(0), a2(1));
4115 g1 = std::sqrt(a1(0)*a1(0) + a2(0)*a2(0));
4116 g2 = std::sqrt(a1(1)*a1(1) + a2(1)*a2(1));
4119 if ((
std::abs(det) < eps*eps*det_o) || (det < 0))
4122 if ((
std::abs(g1) < eps*g1_o) || (g1 < 0))
4125 if ((
std::abs(g2) < eps*g2_o) || (g2 < 0))
4130 metric_file << 1./std::sqrt(det) <<
" " 4131 << 0.5/std::sqrt(det) <<
" \n0.000000e+00 " 4132 << 0.5*std::sqrt(3./det)
4136 metric_file << 1./g1 <<
" " 4137 << 0.5/g2 <<
"\n0.000000e+00 " 4138 << 0.5*std::sqrt(3.)/g2
4160 for (
int k=0; k<3; k++)
4161 for (
int l=0; l<4; l++)
4163 a1(k) += Q[k][l]*R[cells[i][l]][0];
4164 a2(k) += Q[k][l]*R[cells[i][l]][1];
4165 a3(k) += Q[k][l]*R[cells[i][l]][2];
4168 det =
jac3(a1(0), a1(1), a1(2),
4169 a2(0), a2(1), a2(2),
4170 a3(0), a3(1), a3(2));
4171 g1 = std::sqrt(a1(0)*a1(0) + a2(0)*a2(0) + a3(0)*a3(0));
4172 g2 = std::sqrt(a1(1)*a1(1) + a2(1)*a2(1) + a3(1)*a3(1));
4173 g3 = std::sqrt(a1(2)*a1(2) + a2(2)*a2(2) + a3(2)*a3(2));
4176 if ((
std::abs(det) < eps*eps*eps*det_o) || (det < 0))
4179 if ((
std::abs(g1) < eps*g1_o) || (g1 < 0))
4182 if ((
std::abs(g2) < eps*g2_o) || (g2 < 0))
4185 if ((
std::abs(g3) < eps*g3_o) || (g3 < 0))
4190 metric_file << 1./
pow(det, 1./3.)
4191 <<
" 0.000000e+00 0.000000e+00\n0.000000e+00 " 4192 << 1./
pow(det, 1./3.)
4193 <<
" 0.000000e+00\n0.000000e+00 0.000000e+00 " 4194 << 1./
pow(det, 1./3.)
4198 metric_file << 1./g1
4199 <<
" 0.000000e+00 0.000000e+00\n0.000000e+00 " 4201 <<
" 0.000000e+00\n0.000000e+00 0.000000e+00 " 4217 const unsigned node_indices[8] = {0, 1, 3, 2, 4, 5, 7, 6};
4218 const unsigned first_neighbor_indices[8] = {1, 3, 2, 0, 6, 4, 5, 7};
4219 const unsigned second_neighbor_indices[8] = {2, 0, 1, 3, 5, 7, 6, 4};
4220 const unsigned third_neighbor_indices[8] = {4, 5, 7, 6, 0, 1, 3, 2};
4224 for (
unsigned ni=0; ni<8; ++ni)
4227 node_index = node_indices[ni],
4228 first_neighbor_index = first_neighbor_indices[ni],
4229 second_neighbor_index = second_neighbor_indices[ni],
4230 third_neighbor_index = third_neighbor_indices[ni];
4233 node_x = R[cells[i][node_index]][0],
4234 node_y = R[cells[i][node_index]][1],
4235 node_z = R[cells[i][node_index]][2],
4236 first_neighbor_x = R[cells[i][first_neighbor_index]][0],
4237 first_neighbor_y = R[cells[i][first_neighbor_index]][1],
4238 first_neighbor_z = R[cells[i][first_neighbor_index]][2],
4239 second_neighbor_x = R[cells[i][second_neighbor_index]][0],
4240 second_neighbor_y = R[cells[i][second_neighbor_index]][1],
4241 second_neighbor_z = R[cells[i][second_neighbor_index]][2],
4242 third_neighbor_x = R[cells[i][third_neighbor_index]][0],
4243 third_neighbor_y = R[cells[i][third_neighbor_index]][1],
4244 third_neighbor_z = R[cells[i][third_neighbor_index]][2];
4247 Point a1(first_neighbor_x - node_x,
4248 second_neighbor_x - node_x,
4249 third_neighbor_x - node_x);
4252 Point a2(first_neighbor_y - node_y,
4253 second_neighbor_y - node_y,
4254 third_neighbor_y - node_y);
4257 Point a3(first_neighbor_z - node_z,
4258 second_neighbor_z - node_z,
4259 third_neighbor_z - node_z);
4261 det =
jac3(a1(0), a1(1), a1(2),
4262 a2(0), a2(1), a2(2),
4263 a3(0), a3(1), a3(2));
4264 g1 = std::sqrt(a1(0)*a1(0) + a2(0)*a2(0) + a3(0)*a3(0));
4265 g2 = std::sqrt(a1(1)*a1(1) + a2(1)*a2(1) + a3(1)*a3(1));
4266 g3 = std::sqrt(a1(2)*a1(2) + a2(2)*a2(2) + a3(2)*a3(2));
4269 if ((
std::abs(det) < eps*eps*eps*det_o) || (det < 0))
4272 if ((
std::abs(g1) < eps*g1_o) || (g1 < 0))
4275 if ((
std::abs(g2) < eps*g2_o) || (g2 < 0))
4278 if ((
std::abs(g3) < eps*g3_o) || (g3 < 0))
4283 metric_file << 1./
pow(det, 1./3.) <<
" " 4284 << 0.5/
pow(det, 1./3.) <<
" " 4285 << 0.5/
pow(det, 1./3.) <<
"\n0.000000e+00 " 4286 << 0.5*std::sqrt(3.)/
pow(det, 1./3.) <<
" " 4287 << 0.5/(std::sqrt(3.)*
pow(det, 1./3.)) <<
"\n0.000000e+00 0.000000e+00 " 4288 << std::sqrt(2/3.)/
pow(det, 1./3.)
4292 metric_file << 1./g1 <<
" " 4294 << 0.5/g3 <<
"\n0.000000e+00 " 4295 << 0.5*std::sqrt(3.)/g2 <<
" " 4296 << 0.5/(std::sqrt(3.)*g3) <<
"\n0.000000e+00 0.000000e+00 " 4297 << std::sqrt(2./3.)/g3
4311 metric_file.close();
4313 std::ofstream grid_file(grid.c_str());
4314 if (!grid_file.good())
4315 libmesh_error_msg(
"Error opening file: " << grid);
4317 grid_file <<
_dim <<
"\n" <<
_n_nodes <<
"\n" << Ncells <<
"\n0" << std::endl;
4320 grid_file << std::scientific << std::setprecision(6);
4325 for (
unsigned j=0; j<
_dim; j++)
4326 grid_file << R[i][j] <<
" ";
4328 grid_file << mask[i] << std::endl;
4336 while (cells[i][nvert] >= 0)
4339 if ((nvert == 3) || ((
_dim == 3) && (nvert == 4)))
4342 for (
int j=0; j<nvert; j++)
4343 grid_file << cells[i][j] <<
" ";
4345 for (
unsigned j=nvert; j<3*
_dim +
_dim%2; j++)
4348 grid_file << mcells[i] << std::endl;
4351 if ((
_dim == 2) && (nvert == 4))
4354 grid_file << cells[i][0] <<
" " << cells[i][1] <<
" " << cells[i][2] <<
" -1 -1 -1 0" << std::endl;
4355 grid_file << cells[i][1] <<
" " << cells[i][3] <<
" " << cells[i][0] <<
" -1 -1 -1 0" << std::endl;
4356 grid_file << cells[i][3] <<
" " << cells[i][2] <<
" " << cells[i][1] <<
" -1 -1 -1 0" << std::endl;
4357 grid_file << cells[i][2] <<
" " << cells[i][0] <<
" " << cells[i][3] <<
" -1 -1 -1 0" << std::endl;
4363 grid_file << cells[i][0] <<
" " << cells[i][1] <<
" " << cells[i][2] <<
" " << cells[i][4] <<
" -1 -1 -1 -1 -1 -1 0" << std::endl;
4364 grid_file << cells[i][1] <<
" " << cells[i][3] <<
" " << cells[i][0] <<
" " << cells[i][5] <<
" -1 -1 -1 -1 -1 -1 0" << std::endl;
4365 grid_file << cells[i][3] <<
" " << cells[i][2] <<
" " << cells[i][1] <<
" " << cells[i][7] <<
" -1 -1 -1 -1 -1 -1 0" << std::endl;
4366 grid_file << cells[i][2] <<
" " << cells[i][0] <<
" " << cells[i][3] <<
" " << cells[i][6] <<
" -1 -1 -1 -1 -1 -1 0" << std::endl;
4367 grid_file << cells[i][4] <<
" " << cells[i][6] <<
" " << cells[i][5] <<
" " << cells[i][0] <<
" -1 -1 -1 -1 -1 -1 0" << std::endl;
4368 grid_file << cells[i][5] <<
" " << cells[i][4] <<
" " << cells[i][7] <<
" " << cells[i][1] <<
" -1 -1 -1 -1 -1 -1 0" << std::endl;
4369 grid_file << cells[i][7] <<
" " << cells[i][5] <<
" " << cells[i][6] <<
" " << cells[i][3] <<
" -1 -1 -1 -1 -1 -1 0" << std::endl;
4370 grid_file << cells[i][6] <<
" " << cells[i][7] <<
" " << cells[i][4] <<
" " << cells[i][2] <<
" -1 -1 -1 -1 -1 -1 0" << std::endl;
4377 #endif // LIBMESH_ENABLE_VSMOOTHER std::string name(const ElemQuality q)
int solver(int n, const std::vector< int > &ia, const std::vector< int > &ja, const std::vector< double > &a, std::vector< double > &x, const std::vector< double > &b, double eps, int maxite, int msglev)
std::map< dof_id_type, std::vector< dof_id_type > > _hanging_nodes
int basisA(Array2D< double > &Q, int nvert, const std::vector< double > &K, const Array2D< double > &H, int me)
void full_smooth(Array2D< double > &R, const std::vector< int > &mask, const Array2D< int > &cells, const std::vector< int > &mcells, const std::vector< int > &edges, const std::vector< int > &hnodes, double w, const std::vector< int > &iter, int me, const Array3D< double > &H, int adp, int gr)
void adp_renew(const Array2D< double > &R, const Array2D< int > &cells, std::vector< double > &afun, int adp)
float adapt_minimum() const
virtual dof_id_type n_active_elem() const =0
A geometric point in (x,y,z) space associated with a DOF.
double jac2(double x1, double y1, double x2, double y2)
dof_id_type _n_hanging_edges
double minJ(Array2D< double > &R, const std::vector< int > &mask, const Array2D< int > &cells, const std::vector< int > &mcells, double epsilon, double w, int me, const Array3D< double > &H, double vol, const std::vector< int > &edges, const std::vector< int > &hnodes, int msglev, double &Vmin, double &emax, double &qmin, int adp, const std::vector< double > &afun)
double vertex(Array3D< double > &W, Array2D< double > &F, const Array2D< double > &R, const std::vector< int > &cell_in, double epsilon, double w, int nvert, const std::vector< double > &K, const Array2D< double > &H, int me, double vol, int f, double &Vmin, int adp, const std::vector< double > &g, double sigma)
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
long double max(long double a, double b)
const double _percent_to_move
double minq(const Array2D< double > &R, const Array2D< int > &cells, const std::vector< int > &mcells, int me, const Array3D< double > &H, double &vol, double &Vmin)
const unsigned _miniterBC
int readgr(Array2D< double > &R, std::vector< int > &mask, Array2D< int > &cells, std::vector< int > &mcells, std::vector< int > &edges, std::vector< int > &hnodes)
double minJ_BC(Array2D< double > &R, const std::vector< int > &mask, const Array2D< int > &cells, const std::vector< int > &mcells, double epsilon, double w, int me, const Array3D< double > &H, double vol, int msglev, double &Vmin, double &emax, double &qmin, int adp, const std::vector< double > &afun, int NCN)
virtual element_iterator elements_begin()=0
double localP(Array3D< double > &W, Array2D< double > &F, Array2D< double > &R, const std::vector< int > &cell_in, const std::vector< int > &mask, double epsilon, double w, int nvert, const Array2D< double > &H, int me, double vol, int f, double &Vmin, double &qmin, int adp, const std::vector< double > &afun, std::vector< double > &Gloc)
Base class for Replicated and Distributed meshes.
virtual element_iterator elements_end()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
std::vector< float > * _adapt_data
int pcg_par_check(int n, const std::vector< int > &ia, const std::vector< int > &ja, const std::vector< double > &a, double eps, int maxite, int msglev)
double jac3(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
int readmetr(std::string name, Array3D< double > &H)
double maxE(Array2D< double > &R, const Array2D< int > &cells, const std::vector< int > &mcells, int me, const Array3D< double > &H, double v, double epsilon, double w, std::vector< double > &Gamma, double &qmin)
int read_adp(std::vector< double > &afun)
double pow(double a, int b)
void gener(char grid[], int n)
VariationalMeshSmoother(UnstructuredMesh &mesh, double theta=0.5, unsigned miniter=2, unsigned maxiter=5, unsigned miniterBC=5)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static PetscErrorCode Mat * A
int pcg_ic0(int n, const std::vector< int > &ia, const std::vector< int > &ja, const std::vector< double > &a, const std::vector< double > &u, std::vector< double > &x, const std::vector< double > &b, std::vector< double > &r, std::vector< double > &p, std::vector< double > &z, double eps, int maxite, int msglev)
double avertex(const std::vector< double > &afun, std::vector< double > &G, const Array2D< double > &R, const std::vector< int > &cell_in, int nvert, int adp)
const UnstructuredMesh * _area_of_interest
OStreamProxy out(std::cout)
int writegr(const Array2D< double > &R)
long double min(long double a, double b)
A geometric point in (x,y,z) space.
virtual dof_id_type n_nodes() const =0
virtual void smooth() override
void metr_data_gen(std::string grid, std::string metr, int me)