예제 #1
0
Mesh* F2M::buildMesh(){

	if (!_cp)
		return 0;

	if (_mesh)
		delete _mesh;
	_mesh = new Mesh();
	_vnum = 6;

	CorrPtr cp0 = _cp->tipCorr();
	if(!cp0)
		return 0;
	Vertex* * v = createVerts(cp0->P(), cp0->corr()->P());
	v[0]->setC(-cp0->N());
	v[5]->setC(-cp0->corr()->N());
	_vertmap[v] = cp0;

	cp0 = cp0->nextCorr();
	buildMesh(cp0, v);
	map<Vertex**, CorrPtr> * vmap = new map<Vertex**, CorrPtr>();
	vmap->swap(_vertmap);
	cp0->curve()->setShapeChangedHandler(&updateVertsByCurve, (void*)vmap);
	return _mesh;
}
예제 #2
0
// triangle tests
TEUCHOS_UNIT_TEST(tSTK_IO, fields)
{
   RCP<STK_Interface> mesh = buildMesh(8,8);

   std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > > localIds; 
   buildLocalIds(*mesh,localIds);

   FieldContainer vert0, vert1;
   out << "get vertices" << std::endl;
   mesh->getElementVertices(*localIds["eblock-0_0"],vert0);
   mesh->getElementVertices(*localIds["eblock-1_0"],vert1);

   FieldContainer ublock0, tblock0, tblock1;
   ublock0.resize(localIds["eblock-0_0"]->size(),4);
   tblock0.resize(localIds["eblock-0_0"]->size(),4);
   tblock1.resize(localIds["eblock-1_0"]->size(),4);
   out << "assigning" << std::endl;

   assignBlock(ublock0,vert0,xval);
   assignBlock(tblock0,vert0,yval);
   assignBlock(tblock1,vert1,block2);

   mesh->setSolutionFieldData("u","eblock-0_0",*localIds["eblock-0_0"],ublock0);
   mesh->setSolutionFieldData("T","eblock-0_0",*localIds["eblock-0_0"],tblock0);
   mesh->setSolutionFieldData("T","eblock-1_0",*localIds["eblock-1_0"],tblock1);

   out << "write to exodus" << std::endl;

   mesh->writeToExodus("output.exo");
}
예제 #3
0
//-----------------------------------------------------------------------------
//! SLBox::SLBox ctor with min. & max. vectors of the axis aligned box
SLBox::SLBox(SLVec3f min, SLVec3f max, 
             SLstring name, SLMaterial* mat) : SLMesh(name)
{  
    _min.set(min);
    _max.set(max);
    buildMesh(mat);
}
예제 #4
0
/*!
SLSphere::SLSphere ctor for spheric revolution object around the z-axis.
*/
SLSphere::SLSphere(SLfloat sphereRadius,
                     SLint stacks, 
                     SLint slices,
                     SLstring name,
                     SLMaterial* mat) : SLRevolver(name)
{
    assert(slices >= 3 && "Error: Not enough slices.");
    assert(slices >  0 && "Error: Not enough stacks.");
   
    _radius = sphereRadius;
    _stacks = stacks;

    _slices = slices;
    _smoothFirst = true;
    _smoothLast  = true;
    _revAxis.set(0,0,1);
    _revPoints.reserve(stacks+1);

    SLfloat theta = -SL_PI;
    SLfloat phi   = 0;
    SLfloat dTheta= SL_PI / stacks;
   
    for (SLint i=0; i<=stacks; ++i)
    {   SLVec3f p;
        p.fromSpherical(sphereRadius, theta, phi);
        _revPoints.push_back(p);
        theta += dTheta;
    }
   
    buildMesh(mat);
}
bool SrTerrain::init(IDirect3DDevice9* pd3dDevice)
{
	buildMesh(pd3dDevice);
	D3DXCreateTextureFromFile( pd3dDevice,mTextureFile, &mTexture);

	return true;
}
예제 #6
0
//-----------------------------------------------------------------------------
//! SLBox::SLBox ctor with min. & max. coords. of the axis aligned box
SLBox::SLBox(SLfloat minx, SLfloat miny, SLfloat minz,
             SLfloat maxx, SLfloat maxy, SLfloat maxz,
             SLstring name, SLMaterial* mat) : SLMesh(name)
{  
    _min.set(minx, miny, minz);
    _max.set(maxx, maxy, maxz);
    buildMesh(mat);
}
예제 #7
0
void C2M::buildMesh(int s){
	if (_mesh)
		delete _mesh;
	_mesh = new Mesh();
	for(list<RingPtr>::iterator it = _rings.begin(); it != _rings.end(); it++){
		buildMesh(*it, s);
	}
}
예제 #8
0
void CPlanarShadow::setMeshToRenderFrom(IMesh* mesh)
{
	if (Animated == false)
		return;

	buildMesh(mesh);

}
예제 #9
0
void Map::init(){
	//create mesh
	_cached_mesh = std::unique_ptr<glmesh::Mesh>(buildMesh());
	//create shaders
	std::vector<GLuint> shader_list;
	shader_list.push_back(Shader::createShader(gl::VERTEX_SHADER, vertex_shader));
	shader_list.push_back(Shader::createShader(gl::FRAGMENT_SHADER, fragment_shader));
	_shader_program = Shader::createProgram(shader_list);
	std::for_each(shader_list.begin(), shader_list.end(), gl::DeleteShader);
}
예제 #10
0
TEUCHOS_UNIT_TEST(tSTK_IO, transient_fields)
{
   RCP<STK_Interface> mesh = buildMesh(20,20);

   std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > > localIds; 
   buildLocalIds(*mesh,localIds);

   FieldContainer vert0, vert1;
   out << "get vertices" << std::endl;
   mesh->getElementVertices(*localIds["eblock-0_0"],vert0);
   mesh->getElementVertices(*localIds["eblock-1_0"],vert1);

   FieldContainer ublock0, tblock0, tblock1;
   ublock0.resize(localIds["eblock-0_0"]->size(),4);
   tblock0.resize(localIds["eblock-0_0"]->size(),4);
   tblock1.resize(localIds["eblock-1_0"]->size(),4);

   mesh->setupTransientExodusFile("transient.exo");

   out << "assigning 3.0" << std::endl;
   {
      assignBlock(ublock0,vert0,1.0);
      assignBlock(tblock0,vert0,2.0);
      assignBlock(tblock1,vert1,3.0);

      mesh->setSolutionFieldData("u","eblock-0_0",*localIds["eblock-0_0"],ublock0);
      mesh->setSolutionFieldData("T","eblock-0_0",*localIds["eblock-0_0"],tblock0);
      mesh->setSolutionFieldData("T","eblock-1_0",*localIds["eblock-1_0"],tblock1);
   }

   out << "write to exodus: 3.0" << std::endl;
   mesh->writeToExodus(3.0);
   TEST_EQUALITY(mesh->getCurrentStateTime(),3.0); 

   out << "assigning 4.5" << std::endl;
   {
      assignBlock(ublock0,vert0,6.0);
      assignBlock(tblock0,vert0,7.0);
      assignBlock(tblock1,vert1,8.0);

      mesh->setSolutionFieldData("u","eblock-0_0",*localIds["eblock-0_0"],ublock0);
      mesh->setSolutionFieldData("T","eblock-0_0",*localIds["eblock-0_0"],tblock0);
      mesh->setSolutionFieldData("T","eblock-1_0",*localIds["eblock-1_0"],tblock1);
   }

   out << "write to exodus: 4.5" << std::endl;
   mesh->writeToExodus(4.5);
   TEST_EQUALITY(mesh->getCurrentStateTime(),4.5); 

   STK_ExodusReaderFactory factory("transient.exo",2);
   RCP<STK_Interface> mesh_read = factory.buildMesh(MPI_COMM_WORLD);
   TEST_EQUALITY(mesh_read->getInitialStateTime(),4.5);
   TEST_EQUALITY(mesh_read->getCurrentStateTime(),0.0); // writeToExodus has not yet been called
}
예제 #11
0
/**
 *  LinkView constructor.
 *
 *  @param linkProxy        A proxy used to help linking.
 *  @param startPos         The start position/orientation of the view.
 */
LinkView::LinkView(LinkProxyPtr linkProxy, Matrix const &startPos) :
    startPos_(startPos),
    linkProxy_(linkProxy),
    linkDrawMesh_(NULL)
{
	if ( !s_glVisual.value().empty() )
	{
		linkDrawMesh_ = Moo::VisualManager::instance()->get( s_glVisual );
	}
    buildMesh();
}
예제 #12
0
 /**
 -----------------------------------------------------------------------------
 TerrainCircleDecorator
 -----------------------------------------------------------------------------
 */
 TerrainCircleDecorator::TerrainCircleDecorator(const String& name, Scene* scene)
     :mScene(scene)
     ,mBoldSize(1)
     ,mColour(ColourValue::Green)
     ,mOgreManualObject(NULL)
     ,mRadius(2)
     ,mBuildPointCount(-1)
 {
     buildMaterial();
     createOgreManualObject();
     buildMesh();
 }
예제 #13
0
void ISOP2P1::initialize()
{
    /// 读取配置文件.
    config("config");
    /// 构建网格.
    buildMesh();
    /// 构建混合有限元 ISOP1P2 空间.
    buildFEMSpace();
    /// 构建矩阵结构.
    buildMatrixStruct();

    buildMatrix();
};
예제 #14
0
    //-----------------------------------------------------------------------
    void TerrainCircleDecorator::refresh(void)
    {
        if ( getVisible() == false )
            return;

        mTerrainCircleLineList.build( mScene->getTerrainManager(), mCenter, mRadius );
        if ( mBuildPointCount == mTerrainCircleLineList.mCircleLine.size() )
        {
            refreshMesh();
        }else
        {
            buildMesh();
        }
    }
예제 #15
0
/*!
SLCylinder::SLCylinder ctor for cylindric revolution object around the z-axis.
*/
SLCylinder::SLCylinder(SLfloat  cylinderRadius, 
                       SLfloat  cylinderHeight,
                       SLint    stacks, 
                       SLint    slices,
                       SLbool   hasTop, 
                       SLbool   hasBottom,
                       SLstring name,
                       SLMaterial*   mat) : SLRevolver(name)
{  
    assert(slices >= 3 && "Error: Not enough slices.");
    assert(slices >  0 && "Error: Not enough stacks.");
   
    _radius      = cylinderRadius;
    _height      = cylinderHeight;
    _stacks      = stacks;
    _hasTop      = hasTop;
    _hasBottom   = hasBottom;

    _slices      = slices;
    _smoothFirst = hasBottom;
    _smoothLast  = hasTop;
    _revAxis.set(0,0,1);
    SLint nPoints = stacks + 1;
    if (hasTop)    nPoints += 2;
    if (hasBottom) nPoints += 2;
    _revPoints.reserve(nPoints);
   
    SLfloat dHeight = cylinderHeight / stacks;
    SLfloat h = 0;
   
    if (hasBottom) 
    {   // define double points for sharp edges
        _revPoints.push_back(SLVec3f(0,0,0));
        _revPoints.push_back(SLVec3f(cylinderRadius, 0, 0));
    }

    for (SLint i=0; i<=stacks; ++i)
    {   _revPoints.push_back(SLVec3f(cylinderRadius, 0, h));
        h += dHeight;
    }

    if (hasTop) 
    {   // define double points for sharp edges
        _revPoints.push_back(SLVec3f(cylinderRadius, 0, cylinderHeight));  
        _revPoints.push_back(SLVec3f(0,              0, cylinderHeight));
    }
   
    buildMesh(mat);
}
예제 #16
0
  size_t build(Mesh &mesh, const glm::mat4 &transform = glm::mat4(), const glm::vec4 &color=glm::vec4(1)) {
    auto vertex = [&mesh, &transform, &color](const glm::vec3 &pos, const glm::vec3 &normal, const glm::vec2 &uv) {
      mesh.addVertexTransformed(transform, pos, normal, uv, color);
    };

    auto index = [&mesh](size_t idx) {
      mesh.addIndex(idx);
    };

    size_t firstIndex = mesh.vertices().size();

    buildMesh(vertex, index, firstIndex);
    
    // return the first index of the mesh
    return firstIndex;
  }
예제 #17
0
  size_t build(Mesh &mesh, const glm::mat4 &transform = glm::mat4(), const glm::vec4 &color=glm::vec4(1), int num_y_segments=1, int num_radial_segments=16, Feature features=(Feature)(top|body|bottom)) {
    auto vertex = [&mesh, &transform, &color](const glm::vec3 &pos, const glm::vec3 &normal, const glm::vec2 &uv) {
      mesh.addVertexTransformed(transform, pos, normal, uv, color);
    };

    auto index = [&mesh](size_t idx) {
      mesh.addIndex(idx);
    };

    size_t first_index = mesh.vertices().size();

    buildMesh(vertex, index, first_index, num_y_segments, num_radial_segments, features);
    
    // return the first index of the mesh
    return first_index;
  }
bool CExporter::exportMesh(const std::wstring& strFilename)
{
	checkMeshExpType();

	if (!buildMesh())
	{
		return false;
	}
	for (DWORD i = 0; i < m_meshes.size(); ++i)
	{
		grp::MeshExporter* mesh = m_meshes[i];
		if (mesh == NULL)
		{
			continue;
		}
		std::wstring strFilePath = strFilename;
		if (m_meshes.size() > 1)
		{
			strFilePath += L"_";
			strFilePath += mesh->getName();
		}
		strFilePath += FILE_EXT_MESH_SKIN;

		std::fstream file;
		file.open(strFilePath.c_str(), std::ios_base::out | std::ios_base::binary);
		if (!file.is_open())
		{
			char szError[1024];
			::StringCchPrintf(szError, sizeof(szError), "Failed to open file [%s]", strFilePath.c_str());
			setLastError(szError);
			return false;
		}

		if (!mesh->exportTo(file,
							  (m_options.exportType & EXP_MESH_COMPRESS_POS) != 0,
							  (m_options.exportType & EXP_MESH_COMPRESS_NORMAL) != 0,
							  (m_options.exportType & EXP_MESH_COMPRESS_TEXCOORD) != 0,
							  (m_options.exportType & EXP_MESH_COMPRESS_WEIGHT) != 0))
		{
			file.close();
			return false;
		}
		file.close();
	}
	return true;
}
예제 #19
0
CPlanarShadow::CPlanarShadow(scene::ISceneNode*parent, scene::ISceneManager *mgr, IMesh *mesh, float divisor)
	: ISceneNode(parent, mgr, -1), Vertices(0), Indices(0), SceneManager(mgr), Divisor(divisor), enableDepth(false)
{

	s32 i;
	s32 totalVertices = 0;
	s32 totalIndices = 0;
	s32 bufcnt = mesh->getMeshBufferCount();
	IMeshBuffer* b;

	for (i=0; i<bufcnt; ++i)
	{
		b = mesh->getMeshBuffer(i);
		totalIndices += b->getIndexCount();
		totalVertices += b->getVertexCount();
	}



	Vertices = new core::vector3df[totalVertices];
	Indices = new u16[totalIndices];

	int indStart = 0, vtxNow = 0;

	for (i=0; i < bufcnt; ++i)
	{
		b = mesh->getMeshBuffer(i);

		u16* buff = b->getIndices();

		for (int o = 0; o < b->getIndexCount(); o++)
		{
			Indices[indStart++] = buff[o] + vtxNow;
		}

		vtxNow += b->getVertexCount();

	}

	VertexCount = totalVertices;
	IndexCount = totalIndices;



	buildMesh(mesh);
}
예제 #20
0
  size_t build(Mesh &mesh, const glm::mat4 &transform = glm::mat4{1}, const glm::vec4 &color=glm::vec4(1), int num_subdivs=8) {
    //int vi = 0;
    auto vertex = [&](const glm::vec3 &pos, const glm::vec3 &normal, const glm::vec2 &uv) {
      mesh.addVertexTransformed(transform, pos, normal, uv, color);
    };

    auto index = [&](size_t idx) {
      mesh.addIndex(idx);
    };

    size_t first_index = mesh.vertices().size();

    buildMesh(vertex, index, first_index, num_subdivs);
    
    // return the first index of the mesh
    return first_index;
  }
void TrilinearElementTypeSuite_TestShape( TrilinearElementTypeSuiteData* data ) {
   FeMesh*   mesh = NULL;
   int       nEls, nVerts, nDims;
   const int *verts;
   double*   vert = NULL;
   double    lCrd[3] = { 0.0, 0.0, 0.0 };
   double    basis[8] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
   IArray*   inc;
   int       e_i, v_i, v_j;

   mesh = buildMesh();
   pcu_check_true( mesh );
   Stg_Component_Initialise( mesh, data, True );

   nDims = Mesh_GetDimSize( mesh );
   nEls = Mesh_GetDomainSize( mesh, nDims );
   inc = IArray_New();

   for( e_i = 0; e_i < nEls; e_i++ ) {
      Mesh_GetIncidence( mesh, nDims, e_i, 0, inc );
      nVerts = IArray_GetSize( inc );
      verts = IArray_GetPtr( inc );

      for( v_i = 0; v_i < nVerts; v_i++ ) {
         vert = Mesh_GetVertex( mesh, verts[v_i] );
         FeMesh_CoordGlobalToLocal( mesh, e_i, vert, lCrd );
         FeMesh_EvalBasis( mesh, e_i, lCrd, basis );

         for( v_j = 0; v_j < nVerts; v_j++ ) {
            if( (v_i == v_j && !Num_Approx( basis[v_j], 1.0 )) || (v_i != v_j && !Num_Approx( basis[v_j], 0.0 )) ) {
               break;
            }
         }
         if( v_j < nVerts )
            break;
      }
      if( v_i < nVerts )
         break;
   }
   pcu_check_true( e_i == nEls );

   Stg_Class_Delete( inc );

   _Stg_Component_Delete( mesh );
}
예제 #22
0
//-----------------------------------------------------------------------------
//! SLRectangle ctor with min & max corners and its resolutions 
SLRectangle::SLRectangle(SLVec2f min, SLVec2f max,
                         SLuint resX, SLuint resY, 
                         SLstring name,
                         SLMaterial* mat) : SLMesh(name) 
{
    assert(min!=max);
    assert(resX>0);
    assert(resY>0);
    assert(name!="");
    _min = min;
    _max = max;
    _tmin.set(0,0);
    _tmax.set(1,1);
    _resX = resX;
    _resY = resY;
    _isVolume = true;
    buildMesh(mat);
}
예제 #23
0
void ISOP2P1::initialize()
{
	/// 读取配置文件.
	config("config");
	
	/// debug
	config_debug();
	getchar();
	/// 构建网格.
	buildMesh();
	/// 构建混合有限元 ISOP1P2 空间. 
	buildFEMSpace();
	/// 构建稀疏矩阵模板.
	buildMatrixStruct();
	/// 构建矩阵.
	buildMatrix();
	if (Stokes_init == 1 || NS_init == 1)
		solveStokes();
};
예제 #24
0
void F2M::buildMesh(){

	if (!_cp)
		return;

	if (_mesh)
		delete _mesh;
	_mesh = new Mesh();
	_mesh->eye = Eye::get()->P;
	_vnum = 6;

	CorrPtr cp0 = _cp->tipCorr();
	VertexPtr * v = createVerts(cp0->P(), cp0->corr()->P());
	v[0]->setN(-cp0->N());
	v[5]->setN(-cp0->corr()->N());
	
	cp0 = cp0->nextCorr();
	buildMesh(cp0, v);
}
예제 #25
0
파일: voxels.c 프로젝트: kyle1320/voxels
void renderChunk(Chunk *chunk) {
    // free the previously used buffers. Memory leaks are bad, mmkay.
    if (chunk->mesh)
        freeMesh(chunk->mesh);

    // 6 faces per cube * 2 triangles per face * 3 vertices per triangle * 3 coordinates per vertex
    unsigned int max_points = countChunkSize(chunk);//6 * 6 * 3 * CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE;

    // don't render an empty chunk :p
    if (max_points == 0) {
        *chunk->mesh = EMPTY_MESH;
        return;
    }

    GLfloat *points = malloc(max_points * sizeof(GLfloat));
    GLfloat *normals = malloc(max_points * sizeof(GLfloat));
    GLfloat *colors = malloc(max_points * sizeof(GLfloat));

    int size;

    if (useMeshing)
        size = renderChunkWithMeshing(chunk, points, normals, colors, (vec3){0, 0, 0}, 1.0);
    else
        size = renderChunkToArrays(chunk, points, normals, colors, (vec3){0, 0, 0}, 1.0);

    buildMesh(chunk->mesh, points, normals, colors, NULL, NULL,
              size * sizeof(GLfloat), size * sizeof(GLfloat),
              size * sizeof(GLfloat), 0, 0,
              size / 3);

    translate_m4(chunk->mesh->modelMatrix,
                 chunk->x * CHUNK_WIDTH,
                 chunk->y * CHUNK_WIDTH,
                 chunk->z * CHUNK_WIDTH);

    free(points);
    free(normals);
    free(colors);
}
예제 #26
0
	AssetLoader::meshptr_type AssimpAssetLoader::loadMeshByName(const std::string name)
	{
		AssertAssetOpen();
		
		aiNode *n;
		if(name == "")
			n = mScene->mRootNode;
		else
			n = mScene->mRootNode->FindNode(aiString(name));

		meshptr_type mesh = NULL;
		if(n != NULL)
		{
			std::cout << "found " << name << std::endl;
			mesh = buildMesh(*mScene->mRootNode);
		}
		else
		{
			std::cout << "did not find " << name << std::endl;
		}
		return mesh;
	}
예제 #27
0
파일: voxels.c 프로젝트: kyle1320/voxels
void buildBlockFrame(Mesh *mesh) {
    const GLfloat C0_0 = - 1*BLOCK_WIDTH/64;
    const GLfloat C0_1 =   1*BLOCK_WIDTH/64;
    const GLfloat C1_0 =  63*BLOCK_WIDTH/64;
    const GLfloat C1_1 =  65*BLOCK_WIDTH/64;

    GLfloat points[] = {
        C0_0, C0_0, C0_0, C0_0, C0_0, C0_1, C0_0, C0_1, C0_0, C0_0, C0_1, C0_1,
        C0_1, C0_0, C0_0, C0_1, C0_0, C0_1, C0_1, C0_1, C0_0, C0_1, C0_1, C0_1,
        C0_0, C0_0, C1_0, C0_0, C0_0, C1_1, C0_0, C0_1, C1_0, C0_0, C0_1, C1_1,
        C0_1, C0_0, C1_0, C0_1, C0_0, C1_1, C0_1, C0_1, C1_0, C0_1, C0_1, C1_1,
        C0_0, C1_0, C0_0, C0_0, C1_0, C0_1, C0_0, C1_1, C0_0, C0_0, C1_1, C0_1,
        C0_1, C1_0, C0_0, C0_1, C1_0, C0_1, C0_1, C1_1, C0_0, C0_1, C1_1, C0_1,
        C0_0, C1_0, C1_0, C0_0, C1_0, C1_1, C0_0, C1_1, C1_0, C0_0, C1_1, C1_1,
        C0_1, C1_0, C1_0, C0_1, C1_0, C1_1, C0_1, C1_1, C1_0, C0_1, C1_1, C1_1,
        C1_0, C0_0, C0_0, C1_0, C0_0, C0_1, C1_0, C0_1, C0_0, C1_0, C0_1, C0_1,
        C1_1, C0_0, C0_0, C1_1, C0_0, C0_1, C1_1, C0_1, C0_0, C1_1, C0_1, C0_1,
        C1_0, C0_0, C1_0, C1_0, C0_0, C1_1, C1_0, C0_1, C1_0, C1_0, C0_1, C1_1,
        C1_1, C0_0, C1_0, C1_1, C0_0, C1_1, C1_1, C0_1, C1_0, C1_1, C0_1, C1_1,
        C1_0, C1_0, C0_0, C1_0, C1_0, C0_1, C1_0, C1_1, C0_0, C1_0, C1_1, C0_1,
        C1_1, C1_0, C0_0, C1_1, C1_0, C0_1, C1_1, C1_1, C0_0, C1_1, C1_1, C0_1,
        C1_0, C1_0, C1_0, C1_0, C1_0, C1_1, C1_0, C1_1, C1_0, C1_0, C1_1, C1_1,
        C1_1, C1_0, C1_0, C1_1, C1_0, C1_1, C1_1, C1_1, C1_0, C1_1, C1_1, C1_1,
    };

    GLfloat normals[] = {
        REP_8(REP_8(REP_8(0)))
    };

    GLfloat colors[] = {
        REP_8(REP_8(REP_3(0)))
        /*0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1,
        0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1,
        1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
        0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
        1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
        1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
        1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0*/
    };

    #define IND(x,y) (x * 8 + y)

    #define OUTER_FACE(a, b, c, d) \
            IND(a, a), IND(b, b), IND(b, d), IND(a, a), IND(b, d), IND(a, c), \
            IND(b, d), IND(b, b), IND(c, c), IND(b, d), IND(c, c), IND(c, a), \
            IND(d, b), IND(c, a), IND(c, c), IND(d, b), IND(c, c), IND(d, d), \
            IND(a, a), IND(a, c), IND(d, b), IND(a, a), IND(d, b), IND(d, d)

    #define INNER_FACE(a, b, c, d, e, f, g, h) \
            IND(a, g), IND(b, h), IND(b, e), IND(a, g), IND(b, e), IND(a, f), \
            IND(c, e), IND(c, f), IND(b, g), IND(c, e), IND(b, g), IND(b, h), \
            IND(d, g), IND(c, h), IND(c, e), IND(d, g), IND(c, e), IND(d, f), \
            IND(d, e), IND(d, f), IND(a, g), IND(d, e), IND(a, g), IND(a, h)

    GLuint indices[] = {
        OUTER_FACE(7, 5, 4, 6),
        OUTER_FACE(7, 6, 2, 3),
        OUTER_FACE(7, 3, 1, 5),
        OUTER_FACE(0, 1, 3, 2),
        OUTER_FACE(0, 4, 5, 1),
        OUTER_FACE(0, 2, 6, 4),

        INNER_FACE(7, 5, 4, 6, 3, 1, 0, 2),
        INNER_FACE(7, 6, 2, 3, 5, 4, 0, 1),
        INNER_FACE(7, 3, 1, 5, 6, 2, 0, 4),
        INNER_FACE(0, 1, 3, 2, 4, 5, 7, 6),
        INNER_FACE(0, 4, 5, 1, 2, 6, 7, 3),
        INNER_FACE(0, 2, 6, 4, 1, 3, 7, 5),
    };

    #undef IND
    #undef OUTER_FACE
    #undef INNER_FACE

    buildMesh(mesh, points, normals, colors, NULL, indices,
              sizeof(points), sizeof(normals),
              sizeof(colors), 0, sizeof(indices),
              (sizeof(indices) / sizeof(GLuint)));
}
예제 #28
0
	virtual const ci::gl::VboMesh*	getMesh() {
		if (!mMeshBuilt) buildMesh();
		if (mMesh.getNumIndices() < 1) return nullptr;
		return &mMesh;
	}
예제 #29
0
TEUCHOS_UNIT_TEST(gs_evaluators, gather_constr)
{
    PHX::KokkosDeviceSession session;

    const std::size_t workset_size = 20;
    Teuchos::RCP<panzer::BasisIRLayout> linBasis = buildLinearBasis(workset_size);

    Teuchos::RCP<std::vector<std::string> > fieldNames
        = Teuchos::rcp(new std::vector<std::string>);
    fieldNames->push_back("dog");

    Teuchos::ParameterList pl;
    pl.set("Basis",linBasis);
    pl.set("Field Names",fieldNames);

    Teuchos::RCP<panzer_stk_classic::STK_Interface> mesh = buildMesh(2,2);

    RCP<Epetra_Comm> Comm = Teuchos::rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

    Teuchos::RCP<Teuchos::ParameterList> ipb = Teuchos::parameterList("Physics Blocks");
    std::vector<panzer::BC> bcs;
    testInitialzation(ipb, bcs);

    Teuchos::RCP<panzer::FieldManagerBuilder> fmb =
        Teuchos::rcp(new panzer::FieldManagerBuilder);

    // build physics blocks
    //////////////////////////////////////////////////////////////
    Teuchos::RCP<user_app::MyFactory> eqset_factory = Teuchos::rcp(new user_app::MyFactory);
    user_app::BCFactory bc_factory;
    std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;

    {
        std::map<std::string,std::string> block_ids_to_physics_ids;
        block_ids_to_physics_ids["eblock-0_0"] = "test physics";
        block_ids_to_physics_ids["eblock-1_0"] = "test physics";

        std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
        block_ids_to_cell_topo["eblock-0_0"] = mesh->getCellTopology("eblock-0_0");
        block_ids_to_cell_topo["eblock-1_0"] = mesh->getCellTopology("eblock-1_0");

        Teuchos::RCP<panzer::GlobalData> gd = panzer::createGlobalData();

        int default_integration_order = 1;

        panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
                                   block_ids_to_cell_topo,
                                   ipb,
                                   default_integration_order,
                                   workset_size,
                                   eqset_factory,
                                   gd,
                                   false,
                                   physicsBlocks);
    }

    Teuchos::RCP<panzer_stk_classic::WorksetFactory> wkstFactory
        = Teuchos::rcp(new panzer_stk_classic::WorksetFactory(mesh)); // build STK workset factory
    Teuchos::RCP<panzer::WorksetContainer> wkstContainer     // attach it to a workset container (uses lazy evaluation)
        = Teuchos::rcp(new panzer::WorksetContainer(wkstFactory,physicsBlocks,workset_size));

    // build DOF Manager
    /////////////////////////////////////////////////////////////

    // build the connection manager
    const Teuchos::RCP<panzer::ConnManager<int,int> >
    conn_manager = Teuchos::rcp(new panzer_stk_classic::STKConnManager<int>(mesh));

    panzer::DOFManagerFactory<int,int> globalIndexerFactory;
    RCP<panzer::UniqueGlobalIndexer<int,int> > dofManager
        = globalIndexerFactory.buildUniqueGlobalIndexer(Teuchos::opaqueWrapper(MPI_COMM_WORLD),physicsBlocks,conn_manager);

    Teuchos::RCP<panzer::EpetraLinearObjFactory<panzer::Traits,int> > eLinObjFactory
        = Teuchos::rcp(new panzer::EpetraLinearObjFactory<panzer::Traits,int>(Comm.getConst(),dofManager));
    Teuchos::RCP<panzer::LinearObjFactory<panzer::Traits> > linObjFactory = eLinObjFactory;

    // setup field manager build
    /////////////////////////////////////////////////////////////

    // Add in the application specific closure model factory
    user_app::MyModelFactory_TemplateBuilder cm_builder;
    panzer::ClosureModelFactory_TemplateManager<panzer::Traits> cm_factory;
    cm_factory.buildObjects(cm_builder);

    Teuchos::ParameterList closure_models("Closure Models");
    closure_models.sublist("solid").sublist("SOURCE_TEMPERATURE").set<double>("Value",1.0);
    closure_models.sublist("ion solid").sublist("SOURCE_ION_TEMPERATURE").set<double>("Value",1.0);

    Teuchos::ParameterList user_data("User Data");

    fmb->setWorksetContainer(wkstContainer);
    fmb->setupVolumeFieldManagers(physicsBlocks,cm_factory,closure_models,*linObjFactory,user_data);
    fmb->setupBCFieldManagers(bcs,physicsBlocks,*eqset_factory,cm_factory,bc_factory,closure_models,*linObjFactory,user_data);

    fmb->writeVolumeGraphvizDependencyFiles("field_manager",physicsBlocks);

    panzer::AssemblyEngine_TemplateManager<panzer::Traits> ae_tm;
    panzer::AssemblyEngine_TemplateBuilder builder(fmb,linObjFactory);
    ae_tm.buildObjects(builder);

    RCP<panzer::EpetraLinearObjContainer> eGhosted
        = Teuchos::rcp_dynamic_cast<panzer::EpetraLinearObjContainer>(linObjFactory->buildGhostedLinearObjContainer());
    RCP<panzer::EpetraLinearObjContainer> eGlobal
        = Teuchos::rcp_dynamic_cast<panzer::EpetraLinearObjContainer>(linObjFactory->buildLinearObjContainer());
    eLinObjFactory->initializeGhostedContainer(panzer::EpetraLinearObjContainer::X |
            panzer::EpetraLinearObjContainer::DxDt |
            panzer::EpetraLinearObjContainer::F |
            panzer::EpetraLinearObjContainer::Mat,*eGhosted);
    eLinObjFactory->initializeContainer(panzer::EpetraLinearObjContainer::X |
                                        panzer::EpetraLinearObjContainer::DxDt |
                                        panzer::EpetraLinearObjContainer::F |
                                        panzer::EpetraLinearObjContainer::Mat,*eGlobal);
    panzer::AssemblyEngineInArgs input(eGhosted,eGlobal);

    ae_tm.getAsObject<panzer::Traits::Residual>()->evaluate(input);
    ae_tm.getAsObject<panzer::Traits::Jacobian>()->evaluate(input);
}
예제 #30
0
  TEUCHOS_UNIT_TEST(gather_orientation, gather_constr)
  {

    const std::size_t workset_size = 4;
    const std::string fieldName_q1 = "U";
    const std::string fieldName_qedge1 = "V";

    Teuchos::RCP<panzer_stk_classic::STK_Interface> mesh = buildMesh(2,2);

    // build input physics block
    Teuchos::RCP<panzer::PureBasis> basis_q1 = buildBasis(workset_size,"Q1");
    Teuchos::RCP<panzer::PureBasis> basis_qedge1 = buildBasis(workset_size,"QEdge1");

    Teuchos::RCP<Teuchos::ParameterList> ipb = Teuchos::parameterList();
    testInitialization(ipb);

    const int default_int_order = 1;
    std::string eBlockID = "eblock-0_0";    
    Teuchos::RCP<user_app::MyFactory> eqset_factory = Teuchos::rcp(new user_app::MyFactory);
    panzer::CellData cellData(workset_size,mesh->getCellTopology("eblock-0_0"));
    Teuchos::RCP<panzer::GlobalData> gd = panzer::createGlobalData();
    Teuchos::RCP<panzer::PhysicsBlock> physicsBlock = 
      Teuchos::rcp(new PhysicsBlock(ipb,eBlockID,default_int_order,cellData,eqset_factory,gd,false));

    Teuchos::RCP<std::vector<panzer::Workset> > work_sets = panzer_stk_classic::buildWorksets(*mesh,*physicsBlock); 
    TEST_EQUALITY(work_sets->size(),1);

    // build connection manager and field manager
    const Teuchos::RCP<panzer::ConnManager<int,int> > conn_manager = Teuchos::rcp(new panzer_stk_classic::STKConnManager<int>(mesh));
    RCP<panzer::DOFManager<int,int> > dofManager = Teuchos::rcp(new panzer::DOFManager<int,int>(conn_manager,MPI_COMM_WORLD));
    dofManager->addField(fieldName_q1,Teuchos::rcp(new panzer::Intrepid2FieldPattern(basis_q1->getIntrepid2Basis())));
    dofManager->addField(fieldName_qedge1,Teuchos::rcp(new panzer::Intrepid2FieldPattern(basis_qedge1->getIntrepid2Basis())));
    dofManager->setOrientationsRequired(true);
    dofManager->buildGlobalUnknowns();

    // setup field manager, add evaluator under test
    /////////////////////////////////////////////////////////////
 
    PHX::FieldManager<panzer::Traits> fm;

    Teuchos::RCP<PHX::FieldTag> evalField_q1, evalField_qedge1;
    {
       Teuchos::RCP<std::vector<std::string> > dofNames = Teuchos::rcp(new std::vector<std::string>);
       dofNames->push_back(fieldName_q1);

       Teuchos::ParameterList pl;
       pl.set("Indexer Names",dofNames);
       pl.set("DOF Names",dofNames);
       pl.set("Basis",basis_q1);

       Teuchos::RCP<PHX::Evaluator<panzer::Traits> > evaluator  
          = Teuchos::rcp(new panzer::GatherOrientation<panzer::Traits::Residual,panzer::Traits,int,int>(dofManager,pl));

       TEST_EQUALITY(evaluator->evaluatedFields().size(),1);
       evalField_q1 = evaluator->evaluatedFields()[0];

       TEST_EQUALITY(evalField_q1->name(),basis_q1->name()+" Orientation");
       TEST_EQUALITY(evalField_q1->dataLayout().dimension(0),basis_q1->functional->dimension(0));
       TEST_EQUALITY(evalField_q1->dataLayout().dimension(1),basis_q1->functional->dimension(1));

       fm.registerEvaluator<panzer::Traits::Residual>(evaluator);
       fm.requireField<panzer::Traits::Residual>(*evaluator->evaluatedFields()[0]);
    }
    {
       Teuchos::RCP<std::vector<std::string> > dofNames = Teuchos::rcp(new std::vector<std::string>);
       dofNames->push_back(fieldName_qedge1);

       Teuchos::ParameterList pl;
       pl.set("Indexer Names",dofNames);
       pl.set("DOF Names",dofNames);
       pl.set("Basis",basis_qedge1);

       Teuchos::RCP<PHX::Evaluator<panzer::Traits> > evaluator  
          = Teuchos::rcp(new panzer::GatherOrientation<panzer::Traits::Residual,panzer::Traits,int,int>(dofManager,pl));

       TEST_EQUALITY(evaluator->evaluatedFields().size(),1);
       evalField_qedge1 = evaluator->evaluatedFields()[0];

       TEST_EQUALITY(evalField_qedge1->name(),basis_qedge1->name()+" Orientation");
       TEST_EQUALITY(evalField_qedge1->dataLayout().dimension(0),basis_qedge1->functional->dimension(0));
       TEST_EQUALITY(evalField_qedge1->dataLayout().dimension(1),basis_qedge1->functional->dimension(1));

       fm.registerEvaluator<panzer::Traits::Residual>(evaluator);
       fm.requireField<panzer::Traits::Residual>(*evaluator->evaluatedFields()[0]);
    }

    panzer::Traits::SetupData sd;
    fm.postRegistrationSetup(sd);

    // run tests
    /////////////////////////////////////////////////////////////

    panzer::Workset & workset = (*work_sets)[0];
    workset.alpha = 0.0;
    workset.beta = 0.0;
    workset.time = 0.0;
    workset.evaluate_transient_terms = false;

    fm.evaluateFields<panzer::Traits::Residual>(workset);

    // <cell,basis>
    PHX::MDField<panzer::Traits::Residual::ScalarT> 
       fieldData_q1(evalField_q1->name(),basis_q1->functional);
    // <cell,basis>
    PHX::MDField<panzer::Traits::Residual::ScalarT> 
       fieldData_qedge1(evalField_qedge1->name(),basis_qedge1->functional);

    fm.getFieldData<panzer::Traits::Residual::ScalarT,panzer::Traits::Residual>(fieldData_q1);
    fm.getFieldData<panzer::Traits::Residual::ScalarT,panzer::Traits::Residual>(fieldData_qedge1);

    for(int i=0;i<fieldData_q1.size();i++) {
       TEST_EQUALITY(fieldData_q1[i],1);
    }

    for(int i=0;i<fieldData_qedge1.dimension(0);i++) {
       TEST_EQUALITY(fieldData_qedge1(i,0), 1);
       TEST_EQUALITY(fieldData_qedge1(i,1), 1);
       TEST_EQUALITY(fieldData_qedge1(i,2),-1);
       TEST_EQUALITY(fieldData_qedge1(i,3),-1);
    }
  }