本文整理汇总了C++中MeshImpl类的典型用法代码示例。如果您正苦于以下问题:C++ MeshImpl类的具体用法?C++ MeshImpl怎么用?C++ MeshImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MeshImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NULL_USE
// 输出网格到 VTK 文件
void MeshOpt::writeToVTK(hier::Patch<NDIM>& patch,
const double time,
const double dt,
const bool initial_time)
{
NULL_USE(dt);
NULL_USE(time);
NULL_USE(initial_time);
const tbox::Pointer< hier::BlockPatchGeometry<NDIM> > pgeom =
patch.getPatchGeometry();
int block_index = pgeom->getBlockNumber();
int patch_index = patch.getPatchNumber();
std::stringstream bi, pi, df;
bi << block_index;
pi << patch_index;
df << d_flag;
std::string file_name = df.str() + "_block_ " + bi.str()+ "_patch_" + pi.str() + ".vtk";
MsqError err;
MeshImpl * mesh = createLocalMesh(patch);
mesh->write_vtk(file_name.c_str(), err);
return;
}
示例2: make_mesh
void SlaveBoundaryVerticesTest::make_mesh( MeshImpl& mesh,
DomainClassifier& domain,
const int intervals )
{
MsqPrintError err(std::cerr);
const char input_file[] = MESH_FILES_DIR "3D/VTK/6x6x6-hex20.vtk";
const Vector3D min( -3, -3, -3 );
const Vector3D max( 3, 3, 3 );
const Vector3D space = (max - min) * 1.0/(intervals);
mesh.clear();
mesh.read_vtk( input_file, err );
ASSERT_NO_ERROR(err);
const Vector3D corners[8] = { Vector3D(min[0],min[1],min[2]),
Vector3D(max[0],min[1],min[2]),
Vector3D(max[0],max[1],min[2]),
Vector3D(min[0],max[1],min[2]),
Vector3D(min[0],min[1],max[2]),
Vector3D(max[0],min[1],max[2]),
Vector3D(max[0],max[1],max[2]),
Vector3D(min[0],max[1],max[2]) };
MeshDomain* subdomains[26] = {
new PlanarDomain( PlanarDomain::XZ, min[1] ),
new PlanarDomain( PlanarDomain::YZ, max[0] ),
new PlanarDomain( PlanarDomain::XZ, max[1] ),
new PlanarDomain( PlanarDomain::YZ, min[0] ),
new PlanarDomain( PlanarDomain::XY, min[2] ),
new PlanarDomain( PlanarDomain::XY, max[2] ),
new LineDomain( corners[0], corners[1] - corners[0] ),
new LineDomain( corners[1], corners[2] - corners[1] ),
new LineDomain( corners[2], corners[3] - corners[2] ),
new LineDomain( corners[3], corners[0] - corners[3] ),
new LineDomain( corners[0], corners[4] - corners[0] ),
new LineDomain( corners[1], corners[5] - corners[1] ),
new LineDomain( corners[2], corners[6] - corners[0] ),
new LineDomain( corners[3], corners[7] - corners[1] ),
new LineDomain( corners[4], corners[5] - corners[4] ),
new LineDomain( corners[5], corners[6] - corners[5] ),
new LineDomain( corners[6], corners[7] - corners[6] ),
new LineDomain( corners[7], corners[4] - corners[7] ),
new PointDomain( corners[0] ),
new PointDomain( corners[1] ),
new PointDomain( corners[2] ),
new PointDomain( corners[3] ),
new PointDomain( corners[4] ),
new PointDomain( corners[5] ),
new PointDomain( corners[6] ),
new PointDomain( corners[7] ) };
const int subdims[26] = { 2, 2, 2, 2, 2, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0 };
DomainClassifier::classify_skin_geometrically( domain, &mesh, 1e-6,
subdomains, subdims, 26,
err );
domain.delete_sub_domains(true);
ASSERT_NO_ERROR(err);
}
示例3: test_write
// Test writing VTK unstructured mesh
void VtkTest::test_write()
{
MeshImpl mesh;
MsqPrintError err(cout);
// Create file containing unstructured mesh test case
FILE* file = fopen( temp_file_name, "w+" );
CPPUNIT_ASSERT(file);
int rval = fputs( mixed_unstructured_data, file );
fclose( file );
if (rval == EOF) remove(temp_file_name);
CPPUNIT_ASSERT(rval != EOF);
// Read unstructured mesh file
mesh.read_vtk( temp_file_name, err );
remove(temp_file_name);
ASSERT_NO_ERROR(err);
// Write unstructured mesh file back out
mesh.write_vtk( temp_file_name, err );
if (err) remove( temp_file_name );
ASSERT_NO_ERROR(err);
// Check if file contained expected mesh
test_read_unstructured( temp_file_name );
remove( temp_file_name );
}
示例4: main
int main( int argc, char* argv[] )
{
parse_options( argv, argc );
MeshImpl mesh;
XYRectangle domain( max_x - min_x, max_y - min_y, min_x, min_y );
MsqError err;
create_input_mesh( input_x, mesh, err );
if (MSQ_CHKERR(err)) { std::cerr << err << std::endl; return 2; }
domain.setup( &mesh, err );
if (MSQ_CHKERR(err)) { std::cerr << err << std::endl; return 2; }
QualityMetric* metric = 0;
if (mMetric == 'c')
metric = new ConditionNumberQualityMetric;
else
metric = new IdealWeightInverseMeanRatio;
LPtoPTemplate function( 1, metric );
VertexMover* solver = 0;
if (mSolver == 'j')
solver = new ConjugateGradient( &function );
else
solver = new FeasibleNewton( &function );
if (PatchSetUser* psu = dynamic_cast<PatchSetUser*>(solver))
psu->use_global_patch();
TerminationCriterion inner;
inner.add_absolute_vertex_movement( 1e-4 );
inner.write_mesh_steps( "synchronous", TerminationCriterion::GNUPLOT );
solver->set_inner_termination_criterion( &inner );
InstructionQueue q;
QualityAssessor qa( metric, 10 );
q.add_quality_assessor( &qa, err );
q.set_master_quality_improver( solver, err );
q.add_quality_assessor( &qa, err );
MeshDomainAssoc mesh_and_domain = MeshDomainAssoc(&mesh, &domain);
q.run_instructions( &mesh_and_domain, err );
delete solver;
delete metric;
if (MSQ_CHKERR(err))
{ std::cerr << err << std::endl; return 3; }
mesh.write_vtk( outputFile, err );
if (MSQ_CHKERR(err))
{ std::cerr << err << std::endl; return 2; }
return 0;
}
示例5: get_planar_example
void get_planar_example( const char* filename,
DomainClassifier& geom,
MeshImpl& mesh,
MsqError& err )
{
static PlanarDomain z(PlanarDomain::XY);
mesh.read_vtk(filename, err); MSQ_ERRRTN(err);
mesh.mark_skin_fixed(err); MSQ_ERRRTN(err);
DomainClassifier::DomainSet set(&z);
mesh.get_all_vertices( set.vertices, err ); MSQ_ERRRTN(err);
mesh.get_all_elements( set.elements, err ); MSQ_ERRRTN(err);
DomainClassifier::classify_by_handle( geom, &mesh, &set, 1, err ); MSQ_ERRRTN(err);
}
示例6: run_example
int run_example( const Example& e, bool write_output_file )
{
MsqPrintError err(std::cerr);
MeshImpl mesh;
DomainClassifier domain;
HexLagrangeShape hex27;
std::cout << std::endl
<< "--------------------------------------------------------------------"
<< std::endl
<< e.desc << std::endl
<< "--------------------------------------------------------------------"
<< std::endl;
std::string name = e.func( domain, mesh, err );
if (MSQ_CHKERR(err)) return 2;
std::cout << "Loaded mesh from: " << name << std::endl;
UntangleWrapper untangler;
untangler.set_slaved_ho_node_mode( Settings::SLAVE_NONE );
untangler.set_mapping_function( &hex27 );
MeshDomainAssoc mesh_and_domain = MeshDomainAssoc(&mesh, &domain, false, true);
untangler.run_instructions( &mesh_and_domain, err );
if (MSQ_CHKERR(err)) return 1;
ShapeImprover smoother;
smoother.set_slaved_ho_node_mode( Settings::SLAVE_NONE );
smoother.set_mapping_function( &hex27 );
smoother.set_vertex_movement_limit_factor( 0.05 );
smoother.run_instructions( &mesh_and_domain, err );
if (MSQ_CHKERR(err)) return 1;
if (write_output_file) {
size_t idx = name.find( ".vtk" );
if (idx != std::string::npos) {
std::string newname( name.substr(0, idx) );
newname += ".out";
newname += name.substr(idx);
name.swap(newname);
}
else {
name += ".out";
}
mesh.write_vtk( name.c_str(), err ); MSQ_CHKERR(err);
std::cout << "Write mesh to file: " << name << std::endl;
}
return smoother.quality_assessor().invalid_elements();
}
示例7: test_read_rectilinear_grid
// Test reading 3D Vtk rectilinear-grid mesh
void VtkTest::test_read_rectilinear_grid()
{
MeshImpl mesh;
MsqPrintError err(cout);
FILE* file = fopen( temp_file_name, "w+" );
fputs( rectilinear_grid_data, file );
fclose( file );
mesh.read_vtk( temp_file_name, err );
remove( temp_file_name );
ASSERT_NO_ERROR(err);
check_8hex_structured( mesh );
}
示例8: err
// Test reading 2D Vtk structured-points mesh
void VtkTest::test_read_structured_2d_points()
{
MeshImpl mesh;
MsqPrintError err(cout);
FILE* file = fopen( temp_file_name, "w+" );
fputs( structured_2d_points_data, file );
fclose( file );
mesh.read_vtk( temp_file_name, err );
remove( temp_file_name );
ASSERT_NO_ERROR(err);
check_4quad_structured( mesh );
}
示例9: fopen
void TagVertexMeshTest::setUp()
{
const char vtk_data[] =
"# vtk DataFile Version 2.0\n"
"test mesh\n"
"ASCII\n"
"DATASET UNSTRUCTURED_GRID\n"
"POINTS 3 float\n"
"0 0 0\n"
"1 0 0\n"
"0 1 0\n"
"CELLS 1 4\n"
"3 0 1 2\n"
"CELL_TYPES 1\n"
"5\n";
FILE* file = fopen( TEMP_FILE_NAME, "w" );
CPPUNIT_ASSERT( !!file );
size_t r = fwrite( vtk_data, sizeof(vtk_data)-1, 1, file );
fclose( file );
CPPUNIT_ASSERT( r == 1 );
MsqPrintError err( std::cerr );
realMesh = new MeshImpl;
realMesh->read_vtk( TEMP_FILE_NAME, err );
remove( TEMP_FILE_NAME );
ASSERT_NO_ERROR(err);
}
示例10: test_read_fixed_attrib
// Test reading MeshImpl boundary-vertex bit
// from Vtk scalar attribute.
void VtkTest::test_read_fixed_attrib()
{
MeshImpl mesh;
MsqPrintError err(cout);
FILE* file = fopen( temp_file_name, "w+" );
fputs( structured_3d_points_data, file );
fputs( fixed_vertex_attrib, file );
fclose( file );
mesh.read_vtk( temp_file_name, err );
remove( temp_file_name );
ASSERT_NO_ERROR(err);
std::vector<Mesh::ElementHandle> elems;
mesh.get_all_elements( elems, err );
CPPUNIT_ASSERT( !err );
CPPUNIT_ASSERT_EQUAL( elems.size(), (size_t)8 );
std::vector<Mesh::VertexHandle> verts;
std::vector<size_t> offsets;
mesh.elements_get_attached_vertices( arrptr(elems), elems.size(), verts, offsets, err );
ASSERT_NO_ERROR(err);
// get unique list of vertices
std::vector<Mesh::VertexHandle>::iterator new_end;
std::sort( verts.begin(), verts.end() );
new_end = std::unique( verts.begin(), verts.end() );
verts.resize( new_end - verts.begin() );
CPPUNIT_ASSERT_EQUAL( verts.size(), (size_t)27 );
// get fixed flag
std::vector<bool> fixed;
mesh.vertices_get_fixed_flag( arrptr(verts), fixed, verts.size(), err );
ASSERT_NO_ERROR(err);
CPPUNIT_ASSERT_EQUAL( verts.size(), fixed.size() );
for (int i = 0; i < 27; ++i)
{
bool should_be_fixed = (i != 13);
CPPUNIT_ASSERT_EQUAL( should_be_fixed, (bool)fixed[i] );
}
}
示例11: get_sphere_cylinder_example
std::string get_sphere_cylinder_example( DomainClassifier& geom, MeshImpl& mesh, MsqError& err )
{
const char filename[] = SRCDIR "sphereCylinder_1194_inv.vtk";
const Vector3D vec_k(0,0,8), vec_nk(0,0,-8);
const Vector3D vec_c(0,0,5);
//++ 0D domains ++
//++ 1D domains ++
//top circle
static CircleDomain cr_to(vec_k,vec_k,8.0), cr_ti(vec_k,vec_k,4.0);
//bottom circle
static CircleDomain cr_bo(vec_nk,vec_nk,8.0);
//++ 2D domains ++
static PlanarDomain sf_t(vec_k,vec_k), sf_b(vec_nk,vec_nk);
static CylinderDomain cy(8.0,vec_k,vec_k);
static SphericalDomain sp(vec_c,5.0);
MeshDomain* base_domains[] = {
&cr_to, &cr_ti, &cr_bo,
&sf_t, &sf_b, &cy, &sp
};
const int NDOM = sizeof(base_domains)/sizeof(base_domains[0]);
int dim_array[NDOM] = {
1, 1, 1,
2, 2, 2, 2
};
//++ MESH & DOMAIN ++
mesh.read_vtk(filename, err); MSQ_ERRZERO(err);
DomainClassifier::classify_skin_geometrically (geom, &mesh, 0.001, base_domains, dim_array, NDOM, err);
MSQ_ERRZERO(err);
mesh.set_skin_flags( false, false, true, err ); MSQ_ERRZERO(err);
return filename;
}
示例12: cond_write_file
void cond_write_file( MeshImpl& mesh, const char* filename )
{
if (filename) {
MsqPrintError err(std::cerr);
mesh.write_vtk( filename, err );
if (MSQ_CHKERR(err)) {
std::cerr << filename << ": failed to write file" << std::endl;
exit(1);
}
std::cout << "Wrote file: " << filename << std::endl;
}
}
示例13: test_read_simple_scalar_attrib
// Test reading Vtk simple (one-component) scalar attribute
void VtkTest::test_read_simple_scalar_attrib()
{
MeshImpl mesh;
MsqPrintError err(cout);
FILE* file = fopen( temp_file_name, "w+" );
fputs( structured_3d_points_data, file );
fputs( simple_scalar_attrib, file );
fclose( file );
mesh.read_vtk( temp_file_name, err );
remove( temp_file_name );
ASSERT_NO_ERROR(err);
std::vector<Mesh::ElementHandle> elems;
mesh.get_all_elements( elems, err );
CPPUNIT_ASSERT( !err );
CPPUNIT_ASSERT_EQUAL( elems.size(), (size_t)8 );
void* th = mesh.tag_get( "global_id", err );
CPPUNIT_ASSERT( !err );
std::string name;
Mesh::TagType type;
unsigned tagsize;
mesh.tag_properties( th, name, type, tagsize, err );
CPPUNIT_ASSERT( !err && type == Mesh::INT && tagsize == 1 );
int elem_data[8];
mesh.tag_get_element_data( th, 8, arrptr(elems), elem_data, err );
CPPUNIT_ASSERT( !err );
for (int i = 0; i < 8; ++i)
CPPUNIT_ASSERT( elem_data[i] == (1+i) );
}
示例14: test_read_vector_attrib
// Test reading Vtk vector attribute
void VtkTest::test_read_vector_attrib()
{
MeshImpl mesh;
MsqPrintError err(cout);
FILE* file = fopen( temp_file_name, "w+" );
fputs( structured_3d_points_data, file );
fputs( simple_vector_attrib, file );
fclose( file );
mesh.read_vtk( temp_file_name, err );
remove( temp_file_name );
ASSERT_NO_ERROR(err);
std::vector<Mesh::ElementHandle> elems;
mesh.get_all_elements( elems, err );
CPPUNIT_ASSERT( !err );
CPPUNIT_ASSERT_EQUAL( elems.size(), (size_t)8 );
void* th = mesh.tag_get( "hexvect", err );
CPPUNIT_ASSERT( !err );
std::string name;
Mesh::TagType type;
unsigned tagsize;
mesh.tag_properties( th, name, type, tagsize, err );
CPPUNIT_ASSERT( !err && type == Mesh::DOUBLE && tagsize == 3 );
double elem_data[24];
mesh.tag_get_element_data( th, 8, arrptr(elems), elem_data, err );
CPPUNIT_ASSERT( !err );
for (int i = 0; i < 8; ++i)
CPPUNIT_ASSERT( Vector3D( elem_data+3*i ) == Vector3D( i+1, i+1, i+1 ) );
}
示例15: test_cleanup
void TagVertexMeshTest::test_cleanup()
{
MsqPrintError err( std::cerr );
Vector3D new_coords(5, 5, 5);
MsqVertex get_coords;
std::vector<Mesh::VertexHandle> vertices;
realMesh->get_all_vertices( vertices, err );
ASSERT_NO_ERROR(err);
Mesh::VertexHandle vertex = vertices[0];
realMesh->vertices_get_coordinates( &vertex, &get_coords, 1, err );
ASSERT_NO_ERROR(err);
Vector3D orig_coords = get_coords;
// modify a vertex in the tag interface
{
TagVertexMesh tag_mesh( err, realMesh, true );
ASSERT_NO_ERROR(err);
tag_mesh.vertex_set_coordinates( vertex, new_coords, err );
ASSERT_NO_ERROR(err);
}
// check that values were cleaned up when previous instance was destroyed
{
TagVertexMesh tag_mesh( err, realMesh, false );
ASSERT_NO_ERROR(err);
tag_mesh.vertices_get_coordinates( &vertex, &get_coords, 1, err );
ASSERT_NO_ERROR(err);
CPPUNIT_ASSERT_VECTORS_EQUAL( orig_coords, get_coords, DBL_EPSILON );
}
}