本文整理汇总了C++中NumericVector::l1_norm方法的典型用法代码示例。如果您正苦于以下问题:C++ NumericVector::l1_norm方法的具体用法?C++ NumericVector::l1_norm怎么用?C++ NumericVector::l1_norm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NumericVector
的用法示例。
在下文中一共展示了NumericVector::l1_norm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSolutionNorm
//.........这里部分代码省略.........
unsigned ndofP = msh->GetElementDofNumber(iel, solPType);
unsigned ndofD = msh->GetElementDofNumber(iel, solDType);
// resize
phiV.resize(ndofV);
gradphiV.resize(ndofV * dim);
nablaphiV.resize(ndofV * (3 * (dim - 1) + !(dim - 1)));
solP.resize(ndofP);
for(int d = 0; d < dim; d++) {
solV[d].resize(ndofV);
x0[d].resize(ndofD);
x[d].resize(ndofD);
}
// get local to global mappings
for(unsigned i = 0; i < ndofD; i++) {
unsigned idof = msh->GetSolutionDof(i, iel, solDType);
for(unsigned d = 0; d < dim; d++) {
x0[d][i] = (*msh->_topology->_Sol[d])(idof);
x[d][i] = (*msh->_topology->_Sol[d])(idof) +
(*solution->_Sol[solDIndex[d]])(idof);
}
}
for(unsigned i = 0; i < ndofV; i++) {
unsigned idof = msh->GetSolutionDof(i, iel, solVType); // global to global mapping between solution node and solution dof
for(unsigned d = 0; d < dim; d++) {
solV[d][i] = (*solution->_Sol[solVIndex[d]])(idof); // global extraction and local storage for the solution
}
}
for(unsigned i = 0; i < ndofP; i++) {
unsigned idof = msh->GetSolutionDof(i, iel, solPType);
solP[i] = (*solution->_Sol[solPIndex])(idof);
}
for(unsigned ig = 0; ig < mlSol._mlMesh->_finiteElement[ielt][solVType]->GetGaussPointNumber(); ig++) {
// *** get Jacobian and test function and test function derivatives ***
msh->_finiteElement[ielt][solVType]->Jacobian(x0, ig, weight0, phiV, gradphiV, nablaphiV);
msh->_finiteElement[ielt][solVType]->Jacobian(x, ig, weight, phiV, gradphiV, nablaphiV);
phiP = msh->_finiteElement[ielt][solPType]->GetPhi(ig);
vol0->add(iproc, weight0);
vol->add(iproc, weight);
std::vector < double> SolV2(dim, 0.);
for(unsigned i = 0; i < ndofV; i++) {
for(unsigned d = 0; d < dim; d++) {
SolV2[d] += solV[d][i] * phiV[i];
}
}
double V2 = 0.;
for(unsigned d = 0; d < dim; d++) {
V2 += SolV2[d] * SolV2[d];
}
v2->add(iproc, V2 * weight);
double P2 = 0;
for(unsigned i = 0; i < ndofP; i++) {
P2 += solP[i] * phiP[i];
}
P2 *= P2;
p2->add(iproc, P2 * weight);
}
}
}
p2->close();
v2->close();
vol0->close();
vol->close();
double p2_l2 = p2->l1_norm();
double v2_l2 = v2->l1_norm();
double VOL0 = vol0->l1_norm();
double VOL = vol->l1_norm();
std::cout.precision(14);
std::scientific;
std::cout << " vol0 = " << VOL0 << std::endl;
std::cout << " vol = " << VOL << std::endl;
std::cout << " (vol-vol0)/vol0 = " << (VOL - VOL0) / VOL0 << std::endl;
std::cout << " p_l2 norm / vol = " << sqrt(p2_l2 / VOL) << std::endl;
std::cout << " v_l2 norm / vol = " << sqrt(v2_l2 / VOL) << std::endl;
data[1] = (VOL - VOL0) / VOL0;
data[2] = VOL;
data[3] = sqrt(p2_l2 / VOL);
data[4] = sqrt(v2_l2 / VOL);
delete p2;
delete v2;
delete vol;
}