void createMetaAndBulkData(stk::io::StkMeshIoBroker &exodusFileReader, stk::mesh::FieldDataManager *fieldDataManager)
{
    std::string exodusFileName = unitTestUtils::getOption("-i", "NO_FILE_SPECIFIED");
    ASSERT_NE(exodusFileName, "NO_FILE_SPECIFIED");

    exodusFileReader.add_mesh_database(exodusFileName, stk::io::READ_MESH);

    std::cerr << "Starting To Read Mesh: " << exodusFileName << std::endl;

    exodusFileReader.create_input_mesh();
    stk::mesh::MetaData &stkMeshMetaData = exodusFileReader.meta_data();
    createNodalVectorFields(stkMeshMetaData);

    Teuchos::RCP<stk::mesh::BulkData> arg_bulk_data(new stk::mesh::BulkData(stkMeshMetaData, MPI_COMM_WORLD, false, NULL, fieldDataManager));
    exodusFileReader.set_bulk_data(arg_bulk_data);
    stk::mesh::BulkData& stkMeshBulkData = *arg_bulk_data;

    bool delay_field_data_allocation = true;
    exodusFileReader.populate_mesh(delay_field_data_allocation);
    exodusFileReader.populate_field_data();

    std::cerr << "Finished Reading Mesh: " << exodusFileName << std::endl;

    stk::mesh::Selector allEntities = stkMeshMetaData.universal_part();
    std::vector<unsigned> entityCounts;
    stk::mesh::count_entities(allEntities, stkMeshBulkData, entityCounts);
    size_t numElements = entityCounts[stk::topology::ELEMENT_RANK];
    size_t numNodes = entityCounts[stk::topology::NODE_RANK];

    std::cerr << "Number of elements in " << exodusFileName << " = " << numElements << std::endl;
    std::cerr << "Number of nodes in " << exodusFileName << " = " << numNodes << std::endl;
}
Example #2
0
inline void setupMeshAndFieldsForTest(stk::io::StkMeshIoBroker &stkMeshIoBroker,
        const std::string &displacementFieldName,
        const std::string &velocityFieldName)
{
    const double displacementValue = 1.0;
    const double velocityValue = 2.0;

    const std::string exodusFileName = "generated:1x1x8";
    size_t index = stkMeshIoBroker.add_mesh_database(exodusFileName, stk::io::READ_MESH);
    stkMeshIoBroker.set_active_mesh(index);
    stkMeshIoBroker.create_input_mesh();

    const int numberOfStates = 1;
    stk::mesh::FieldBase *displacementField = declareNodalField(stkMeshIoBroker.meta_data(), displacementFieldName, numberOfStates);
    stk::mesh::FieldBase *velocityField = declareNodalField(stkMeshIoBroker.meta_data(), velocityFieldName, numberOfStates);

    stkMeshIoBroker.populate_bulk_data();

    putDataOnTestField(stkMeshIoBroker.bulk_data(), displacementValue, *displacementField);
    putDataOnTestField(stkMeshIoBroker.bulk_data(), velocityValue, *velocityField);
}