Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STK: Snapshot 05-06-22 13:38 #10501

Merged
merged 1 commit into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stk_io/StkMeshIoBroker.hpp>
#include <stk_mesh/base/BulkData.hpp>
#include <stk_mesh/base/MetaData.hpp>
#include <stk_mesh/base/MeshBuilder.hpp>
#include <stk_mesh/base/Selector.hpp>
#include <stk_util/command_line/CommandLineParser.hpp>
#include <stk_util/command_line/CommandLineParserParallel.hpp>
Expand Down Expand Up @@ -105,14 +106,14 @@ bool read_command_line( int argc, char *argv[], DeleteSmallElementsInputData & i
static bool delete_small_elements(const DeleteSmallElementsInputData& inputData,
const stk::ParallelMachine comm)
{
stk::mesh::MetaData meta;
stk::mesh::BulkData bulk(meta, comm);
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(comm).create();
stk::mesh::MetaData& meta = bulk->mesh_meta_data();

stk::io::fill_mesh_with_auto_decomp(inputData.meshIn, bulk);
stk::io::fill_mesh_with_auto_decomp(inputData.meshIn, *bulk);

// delete infinitesimal elements
double minEdgeLength, maxEdgeLength, minElementVolume, maxElementVolume;
compute_element_quality(bulk, minEdgeLength, maxEdgeLength, minElementVolume, maxElementVolume);
compute_element_quality(*bulk, minEdgeLength, maxEdgeLength, minElementVolume, maxElementVolume);
sierra::Env::outputP0() << "Overall mesh size results: minEdgeLength=" << minEdgeLength << ", maxEdgeLength=" << maxEdgeLength << ", minElementVolume=" << minElementVolume << ", maxElementVolume=" << maxElementVolume << std::endl;

stk::mesh::Selector blockSelector = meta.universal_part();
Expand All @@ -129,7 +130,7 @@ static bool delete_small_elements(const DeleteSmallElementsInputData& inputData,

const double minRetainedElementVolume = inputData.minNodalVolumeSpecified ? inputData.minNodalVolume : (inputData.minRelativeNodalVolume*maxElementVolume);
if (minElementVolume < minRetainedElementVolume)
delete_all_entities_using_nodes_with_nodal_volume_below_threshold(bulk, blockSelector, minRetainedElementVolume);
delete_all_entities_using_nodes_with_nodal_volume_below_threshold(*bulk, blockSelector, minRetainedElementVolume);
else
sierra::Env::outputP0() << "All nodes already have nodal volume larger than " << minRetainedElementVolume << "." << std::endl;

Expand Down
184 changes: 0 additions & 184 deletions packages/percept/src/ngp/example.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion packages/percept/src/percept/FieldTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace percept {

typedef stk::mesh::Field<double, stk::mesh::SimpleArrayTag> GenericFieldType;
typedef stk::mesh::Field<double> GenericFieldType;

typedef stk::mesh::Field<double> ScalarFieldType ;
typedef stk::mesh::Field<int> ScalarIntFieldType ;
Expand Down
35 changes: 13 additions & 22 deletions packages/percept/src/percept/PerceptMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#include <stk_mesh/base/BoundaryAnalysis.hpp>
#include <stk_mesh/base/BulkModification.hpp>
#include <stk_mesh/base/MeshUtils.hpp>
#include <stk_mesh/base/MeshBuilder.hpp>


// FIXME
Expand Down Expand Up @@ -115,7 +116,6 @@
m_isOpen(false),
m_isInitialized(false),
m_isAdopted(false),
m_needsDelete(false),
m_dontCheckState(false),
m_outputActiveChildrenOnly(false),
m_filename(),
Expand Down Expand Up @@ -192,9 +192,10 @@
entity_rank_names.push_back("FAMILY_TREE");
#endif

m_metaData = new stk::mesh::MetaData();
stk::mesh::MeshBuilder builder(m_comm);
m_bulkData = builder.create();
m_metaData = std::shared_ptr<stk::mesh::MetaData>(&m_bulkData->mesh_meta_data(),[](auto ptrWeWontDelete){});
m_metaData->initialize(m_spatialDim, entity_rank_names);
m_bulkData = new stk::mesh::BulkData(*m_metaData, m_comm);

const unsigned p_rank = stk::parallel_machine_rank( m_comm );

Expand All @@ -217,7 +218,6 @@
}
m_isOpen = true;
m_filename = "";
m_needsDelete = true;
}

void PerceptMesh::
Expand Down Expand Up @@ -291,8 +291,6 @@
setProperty("in_filename", in_filename);
setProperty("file_type", type);

m_needsDelete = false;

if (m_isOpen)
{
throw std::runtime_error("percept::Mesh::open: mesh is already opened. Please close() before trying open, or use reopen().");
Expand Down Expand Up @@ -1776,8 +1774,8 @@

// ctor constructor
PerceptMesh::PerceptMesh(const stk::mesh::MetaData* metaData, stk::mesh::BulkData* bulkData, bool isCommitted) :
m_metaData(const_cast<stk::mesh::MetaData *>(metaData)),
m_bulkData(bulkData),
m_metaData(std::shared_ptr<stk::mesh::MetaData>(const_cast<stk::mesh::MetaData*>(metaData),[](auto ptrWeWontDelete){})),
m_bulkData(std::shared_ptr<stk::mesh::BulkData>(bulkData,[](auto ptrWeWontDelete){})),
m_output_file_index(0),
m_iossMeshDataDidPopulate(false),
m_sync_io_regions(false),
Expand All @@ -1789,7 +1787,6 @@
m_isOpen(true),
m_isInitialized(true),
m_isAdopted(true),
m_needsDelete(false),
m_dontCheckState(false),
m_outputActiveChildrenOnly(false),
m_filename(),
Expand Down Expand Up @@ -1842,7 +1839,7 @@

void PerceptMesh::set_bulk_data(stk::mesh::BulkData *bulkData)
{
m_bulkData = bulkData;
m_bulkData = std::shared_ptr<stk::mesh::BulkData>(bulkData,[](auto ptrWeWontDelete){});
m_comm = bulkData->parallel();
if (!Teuchos::is_null(m_iossMeshData) && m_iossMeshData->is_bulk_data_null())
m_iossMeshData->set_bulk_data(*bulkData);
Expand Down Expand Up @@ -1896,13 +1893,8 @@
m_geometry_parts = 0;
m_iossMeshData = Teuchos::null;
m_iossMeshDataOut = Teuchos::null;
if (m_needsDelete)
{
if (m_bulkData) delete m_bulkData;
if (m_metaData) delete m_metaData;
m_metaData = 0;
m_bulkData = 0;
}
m_bulkData.reset();
m_metaData.reset();
}

PerceptMesh::~PerceptMesh()
Expand Down Expand Up @@ -2365,13 +2357,13 @@
switch (m_searchType)
{
case FieldFunction::SIMPLE_SEARCH:
m_searcher = new SimpleSearcher(m_bulkData);
m_searcher = new SimpleSearcher(m_bulkData.get());
break;
case FieldFunction::STK_SEARCH:
{
//int spDim = last_dimension(input_phy_points);
if (get_spatial_dim() == 3)
m_searcher = new STKSearcher(m_bulkData);
m_searcher = new STKSearcher(m_bulkData.get());
else
{
//m_searcher = new STKSearcher<2>(this);
Expand Down Expand Up @@ -2460,7 +2452,7 @@
// The coordinates field will be set to the correct dimension.
// this call creates the MetaData
mesh_data->create_input_mesh();
m_metaData = &mesh_data->meta_data();
m_metaData = mesh_data->meta_data_ptr();

// This defines all fields found on the input mesh as stk fields
if (!m_avoid_add_all_mesh_fields_as_input_fields)
Expand Down Expand Up @@ -2594,7 +2586,6 @@

//----------------------------------
// Process Bulkdata for all Entity Types. Subsetting is possible.
//stk::mesh::BulkData bulk_data(meta_data, comm);

// Read the model (topology, coordinates, attributes, etc)
// from the mesh-file into the mesh bulk data.
Expand All @@ -2603,7 +2594,7 @@
{
mesh_data->populate_bulk_data();
m_iossMeshDataDidPopulate = true;
m_bulkData = &mesh_data->bulk_data();
m_bulkData = mesh_data->bulk_data_ptr();
}

int timestep_count = mesh_data->get_input_io_region()->get_property("state_count").get_int();
Expand Down
10 changes: 4 additions & 6 deletions packages/percept/src/percept/PerceptMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@
void dump_elements_compact(const std::string& partName = "", bool include_family_tree=false);

/// get the low-level bulk data pointer from stk_mesh
inline stk::mesh::BulkData * get_bulk_data() { return m_bulkData; }
inline stk::mesh::BulkData * get_bulk_data() { return m_bulkData.get(); }

/// get the low-level meta data pointer from stk_mesh
inline stk::mesh::MetaData * get_fem_meta_data() { return m_metaData; }
inline stk::mesh::MetaData * get_fem_meta_data() { return m_metaData.get(); }

/// get a pointer to a stk_mesh Part with the given name - if @param partial_string_match_ok, allow a
/// partial match of the part_name with any part found, in the sense that @param part_name can
Expand Down Expand Up @@ -1093,9 +1093,8 @@
Teuchos::RCP<stk::io::StkMeshIoBroker> get_ioss_mesh_data_output() { return m_iossMeshDataOut; }
size_t get_output_file_index() { return m_output_file_index;}
private:
//stk::mesh::MetaData * m_fem_meta_data;
stk::mesh::MetaData * m_metaData;
stk::mesh::BulkData * m_bulkData;
std::shared_ptr<stk::mesh::MetaData> m_metaData;
std::shared_ptr<stk::mesh::BulkData> m_bulkData;
Teuchos::RCP<stk::io::StkMeshIoBroker> m_iossMeshData;
Teuchos::RCP<stk::io::StkMeshIoBroker> m_iossMeshDataOut;

Expand All @@ -1114,7 +1113,6 @@
bool m_isOpen;
bool m_isInitialized;
bool m_isAdopted;
bool m_needsDelete;
bool m_dontCheckState;
bool m_outputActiveChildrenOnly;
std::string m_filename;
Expand Down
Loading