本文整理汇总了C++中Mesh::BeginNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::BeginNode方法的具体用法?C++ Mesh::BeginNode怎么用?C++ Mesh::BeginNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh::BeginNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv)
{
if( argc < 3 )
{
std::cout << "Usage: " << argv[0] << " mesh mesh_out" << std::endl;
return 0;
}
Mesh * m = new Mesh;
m->SetFileOption("VERBOSITY","2");
try{m->Load(argv[1]);} catch(...) { std::cout << "Cannot load the mesh " << argv[1] << std::endl; return -1;}
Mesh::GeomParam t;
t[MEASURE] = CELL | FACE;
t[ORIENTATION] = FACE;
t[NORMAL] = FACE;
//t[BARYCENTER] = CELL;
t[CENTROID] = CELL | FACE;
m->AssignGlobalID(CELL|FACE);
m->PrepareGeometricData(t);
double max[3] = {-1.0e20, -1.0e20, -1.0e20}, min[3] = {1.0e20,1.0e20,1.0e20};
Storage::real c[3] = {0,0,0}, nrm[3] = {0,0,0};
for(Mesh::iteratorNode it = m->BeginNode(); it != m->EndNode(); ++it)
{
it->Centroid(c);
if( c[0] > max[0] ) max[0] = c[0];
if( c[1] > max[1] ) max[1] = c[1];
if( c[2] > max[2] ) max[2] = c[2];
if( c[0] < min[0] ) min[0] = c[0];
if( c[1] < min[1] ) min[1] = c[1];
if( c[2] < min[2] ) min[2] = c[2];
}
if( max[0] <= min[0] ) {std::cout << "strange X " << min[0] << ":" << max[0] << std::endl; return -1;}
if( max[1] <= min[1] ) {std::cout << "strange Y " << min[1] << ":" << max[1] << std::endl; return -1;}
if( max[2] <= min[2] )
{
//2d mesh
if( m->GetDimensions() == 3 )
{
//offset from z-plane
min[2] -= 0.0001;
max[2] += 0.0001;
}
else
{
min[2] = -0.0001;
max[2] = +0.0001;
}
}
std::cout << "Mesh bounds: " << min[0] << ":" << max[0] << " " << min[1] << ":" << max[1] << " " << min[2] << ":" << max[2] << std::endl;
Tag material;
if( m->HaveTag("PERM") ) m->DeleteTag(m->GetTag("PERM"));
Tag vel = m->CreateTag("REFERENCE_VELOCITY",DATA_REAL,CELL,NONE,3);
Tag force = m->CreateTag("FORCE",DATA_REAL,CELL,NONE,1);
Tag tensor = m->CreateTag("PERM",DATA_REAL,CELL,NONE,6);
Tag solution_val = m->CreateTag("REFERENCE_SOLUTION",DATA_REAL,CELL|FACE|EDGE|NODE,NONE,1);
Tag solution_flux = m->CreateTag("REFERENCE_FLUX",DATA_REAL,FACE,FACE,1);
Tag saddle_val = m->CreateTag("SADDLE_SOLUTION",DATA_REAL,CELL,NONE,4);
Tag saddle_flux = m->CreateTag("SADDLE_FLUX",DATA_REAL,FACE,NONE,4);
Tag bndcond = m->CreateTag("BOUNDARY_CONDITION",DATA_REAL,FACE|EDGE,FACE|EDGE,3);
{
Storage::bulk_array name = m->self()->BulkArray(m->CreateTag("PROBLEMNAME",DATA_BULK,MESH,NONE));
name.replace(name.begin(),name.end(),problem_name.begin(),problem_name.end());
}
for(Mesh::iteratorElement it = m->BeginElement(CELL|FACE|EDGE|NODE); it != m->EndElement(); ++it)
{
it->Centroid(c);
if( it->GetElementType() == CELL )
{
Storage::real_array perm = it->RealArray(tensor);
perm[0] = 1.5;
perm[1] = 0.5;
perm[2] = 0.0;
perm[3] = 1.5;
perm[4] = 0.0;
perm[5] = 1.0;
}
Storage::real x = c[0];//(c[0]-min[0])/(max[0]-min[0]);
Storage::real y = c[1];//(c[1]-min[1])/(max[1]-min[1]);
Storage::real z = c[2];//(c[2]-min[2])/(max[2]-min[2]);
Storage::real sol = 16.0*(1-x)*y*(1-y);
Storage::real flux;
Storage::real dsolx = 16*(y-1)*y;
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
verts[1] = mesh->NodeByLocalID(V_ID(i - 0, j - 1, k - 1));
verts[2] = mesh->NodeByLocalID(V_ID(i - 1, j - 0, k - 1));
verts[3] = mesh->NodeByLocalID(V_ID(i - 0, j - 0, k - 1));
verts[4] = mesh->NodeByLocalID(V_ID(i - 1, j - 1, k - 0));
verts[5] = mesh->NodeByLocalID(V_ID(i - 0, j - 1, k - 0));
verts[6] = mesh->NodeByLocalID(V_ID(i - 1, j - 0, k - 0));
verts[7] = mesh->NodeByLocalID(V_ID(i - 0, j - 0, k - 0));
mesh->CreateCell(verts,nvf,numnodes,6);
}
}
}
}
if( cut_grid )
{
for (Mesh::iteratorCell it = mesh->BeginCell(); it != mesh->EndCell(); ++it)
{
Storage::real cnt[3];
it->Centroid(cnt);
if( cnt[0] > 0.25 && cnt[0] < 0.75 && cnt[1] > 0.25 && cnt[1] < 0.75 )
it->Delete();
}
for (Mesh::iteratorElement it = mesh->BeginElement(FACE|EDGE|NODE); it != mesh->EndElement(); ++it)
if( it->nbAdjElements(CELL) == 0 ) it->Delete();
}
if( alpha > 0.0 ) //skewness
{
const double eps = 1.0e-6;
for( Mesh::iteratorNode it = mesh->BeginNode(); it != mesh->EndNode(); ++it)
{
Storage::real_array coords = it->Coords();
Storage::real h = 1.0e20;
ElementArray<Cell> it_cells = it->getCells();
for(int k = 0; k < it_cells.size(); ++k)
{
Storage::real maxmin[6];
maxmin[0] = -1e20;
maxmin[1] = 1e20;
maxmin[2] = -1e20;
maxmin[3] = 1e20;
ElementArray<Node> nodes = it_cells[k].getNodes();
for (ElementArray<Node>::iterator it = nodes.begin(); it != nodes.end(); it++)
{
Storage::real_array cc = it->Coords();
for (int i = 0; i < (int)cc.size(); i++)
{
if (maxmin[2 * i + 0] < cc[i]) maxmin[2 * i + 0] = cc[i]; //max
if (maxmin[2 * i + 1] > cc[i]) maxmin[2 * i + 1] = cc[i]; //min
}
}
h = std::min(h,sqrt((maxmin[2]-maxmin[3])*(maxmin[2]-maxmin[3])+(maxmin[0]-maxmin[1])*(maxmin[0]-maxmin[1])));
}
if( coords[0] > eps && coords[0] < 1.0-eps && coords[1] > eps && coords[1] < 1.0-eps )
{
if( !(coords[0] > 4.0/9.0-eps && coords[0] < 5.0/9.0+eps && coords[1] > 4.0/9.0-eps && coords[1] < 5.0/9.0+eps) )
{
coords[0] += alpha*h*(2.0*rand()/RAND_MAX-1.0);
coords[1] += alpha*h*(2.0*rand()/RAND_MAX-1.0);
}
示例3: main
int main(int argc, char ** argv)
{
if( argc < 3 )
{
std::cout << "Usage: " << argv[0] << " mesh mesh_out [sigma:0.2 incline:1 y_low:0.25 y_high:0.5]" << std::endl;
return 0;
}
Mesh * m = new Mesh;
m->SetFileOption("VERBOSITY","2");
try{m->Load(argv[1]);} catch(...) { std::cout << "Cannot load the mesh " << argv[1] << std::endl; return -1;}
Storage::real sigma = 0.2, y_low = 0.25, y_high = 0.5, alpha = 0.15;
if( argc > 3 ) sigma = atof(argv[3]);
//for(Mesh::iteratorTag t = m->BeginTag(); t != m->EndTag(); ++t)
// if( t->GetTagName().substr(0,9) == "GEOM_UTIL" ) m->DeleteTag(*t);
if( argc <= 4 || (argc > 4 && atoi(argv[4])) )
{
double max[3] = {-1.0e20, -1.0e20, -1.0e20}, min[3] = {1.0e20,1.0e20,1.0e20};
for(Mesh::iteratorNode it = m->BeginNode(); it != m->EndNode(); ++it)
{
Storage::real_array c = it->Coords();
if( c[0] > max[0] ) max[0] = c[0];
if( c[1] > max[1] ) max[1] = c[1];
if( c[2] > max[2] ) max[2] = c[2];
if( c[0] < min[0] ) min[0] = c[0];
if( c[1] < min[1] ) min[1] = c[1];
if( c[2] < min[2] ) min[2] = c[2];
}
std::cout << "You asked to incline the grid to honour discontinuities" << std::endl;
std::cout << "and I assume that the initial grid is rectangular." << std::endl;
for(Mesh::iteratorNode it = m->BeginNode(); it != m->EndNode(); ++it)
{
Storage::real_array c = it->Coords();
Storage::real x = c[0];
Storage::real y = c[1];
Storage::real d = 0.0;
Storage::real y1 = sigma*(x-0.5)+0.475;
Storage::real y2 = sigma*(x-0.5)+0.475+0.05;
if( y <= y_low ) d = y/y_low*(y1-y_low);
else if( y >= y_low && y <= y_high ) d = (y1-y_low) + (y-y_low)/(y_high-y_low)*((y2-y_high)-(y1-y_low));
else d = (1-(y-y_high)/(1-y_high))*(y2-y_high);
c[1] += d;
}
//introduce skewness
/*
for(Mesh::iteratorNode it = m->BeginNode(); it != m->EndNode(); ++it)
{
Storage::real_array c = it->Coords();
Storage::real x = c[0];
Storage::real y = c[1];
Storage::real y1 = sigma*(x-0.5)+0.475;
Storage::real y2 = sigma*(x-0.5)+0.475+0.05;
Storage::real rndx = (rand()*1.0/RAND_MAX*2-1);
Storage::real rndy = (rand()*1.0/RAND_MAX*2-1);
Storage::real h = 1.0e20;
ElementArray<Cell> it_cells = it->getCells();
for(int k = 0; k < it_cells.size(); ++k)
{
Storage::real maxmin[6];
maxmin[0] = -1e20;
maxmin[1] = 1e20;
maxmin[2] = -1e20;
maxmin[3] = 1e20;
ElementArray<Node> nodes = it_cells[k].getNodes();
for (ElementArray<Node>::iterator it = nodes.begin(); it != nodes.end(); it++)
{
Storage::real_array cc = it->Coords();
for (int i = 0; i < (int)cc.size(); i++)
{
if (maxmin[2 * i + 0] < cc[i]) maxmin[2 * i + 0] = cc[i]; //max
if (maxmin[2 * i + 1] > cc[i]) maxmin[2 * i + 1] = cc[i]; //min
}
}
h = std::min(h,sqrt((maxmin[2]-maxmin[3])*(maxmin[2]-maxmin[3])+(maxmin[0]-maxmin[1])*(maxmin[0]-maxmin[1])));
}
if( fabs(y-y1) > 1.0e-9 && fabs(y-y2) > 1.0e-9 && x > 0 && x < 1 && y > 0 && y < 1 )
{
c[0] += rndx*h*alpha;
c[1] += rndy*h*alpha;
}
}
*/
}
Mesh::GeomParam t;
t[MEASURE] = CELL | FACE;
//.........这里部分代码省略.........