Commit 03269df9 authored by vijaysm's avatar vijaysm
Browse files

Merged in vijaysm/coreoptions (pull request #258)

Update CoreOptions
parents 7706bfe7 66595d36
......@@ -91,7 +91,6 @@
#include "ExoIIUtil.hpp"
#include "EntitySequence.hpp"
#include "moab/FileOptions.hpp"
#include "CoreOptions.hpp"
#ifdef LINUX
# include <dlfcn.h>
# include <dirent.h>
......@@ -153,8 +152,6 @@ static void warn_null_array_mesh_tag()
namespace moab {
CoreOptions coreopts(1.0);
using namespace std;
static inline const MeshSet* get_mesh_set( const SequenceManager* sm,
......@@ -475,12 +472,12 @@ ErrorCode Core::load_mesh( const char *file_name,
ErrorCode Core::load_file( const char* file_name,
const EntityHandle* file_set,
const char* options,
const char* setoptions,
const char* set_tag_name,
const int* set_tag_vals,
int num_set_tag_vals )
{
FileOptions opts(options);
FileOptions opts(setoptions);
ErrorCode rval;
ReaderIface::IDTag t = { set_tag_name, set_tag_vals, num_set_tag_vals };
ReaderIface::SubsetList sl = { &t, 1, 0, 0 };
......@@ -703,7 +700,7 @@ ErrorCode Core::write_mesh(const char *file_name,
ErrorCode Core::write_file( const char* file_name,
const char* file_type,
const char* options,
const char* options_string,
const EntityHandle* output_sets,
int num_output_sets,
const Tag* tag_list,
......@@ -711,7 +708,7 @@ ErrorCode Core::write_file( const char* file_name,
{
Range range;
std::copy( output_sets, output_sets+num_output_sets, range_inserter(range) );
return write_file( file_name, file_type, options, range, tag_list, num_tags );
return write_file( file_name, file_type, options_string, range, tag_list, num_tags );
}
ErrorCode Core::write_file( const char* file_name,
......@@ -1137,6 +1134,17 @@ ErrorCode Core::set_coords(Range entity_handles, const double *coords)
}
double Core::get_sequence_multiplier() const
{
return sequenceManager->get_sequence_multiplier();
}
void Core::set_sequence_multiplier(double factor)
{
assert(factor >= 1.0);
sequenceManager->set_sequence_multiplier(factor);
}
//! get global connectivity array for specified entity type
/** Assumes just vertices, no higher order nodes
*/
......@@ -3255,18 +3263,18 @@ ErrorCode Core::side_element(const EntityHandle source_entity,
//-------------------------Set Functions---------------------//
ErrorCode Core::create_meshset(const unsigned int options,
ErrorCode Core::create_meshset(const unsigned int setoptions,
EntityHandle &ms_handle,
int )
{
return sequence_manager()->create_mesh_set( options, ms_handle );
return sequence_manager()->create_mesh_set( setoptions, ms_handle );
}
ErrorCode Core::get_meshset_options( const EntityHandle ms_handle,
unsigned int& options) const
unsigned int& setoptions) const
{
if (!ms_handle) { // root set
options = MESHSET_SET|MESHSET_TRACK_OWNER;
setoptions = MESHSET_SET|MESHSET_TRACK_OWNER;
return MB_SUCCESS;
}
......@@ -3274,18 +3282,18 @@ ErrorCode Core::get_meshset_options( const EntityHandle ms_handle,
if (!set)
return MB_ENTITY_NOT_FOUND;
options = set->flags();
setoptions = set->flags();
return MB_SUCCESS;
}
ErrorCode Core::set_meshset_options( const EntityHandle ms_handle,
const unsigned int options)
const unsigned int setoptions)
{
MeshSet* set = get_mesh_set( sequence_manager(), ms_handle );
if (!set)
return MB_ENTITY_NOT_FOUND;
return set->set_flags(options, ms_handle, a_entity_factory());
return set->set_flags(setoptions, ms_handle, a_entity_factory());
}
......@@ -3906,13 +3914,13 @@ ErrorCode Core::create_set_iterator(EntityHandle meshset,
SetIterator *&set_iter)
{
// check the type of set
unsigned int options;
unsigned int setoptions;
ErrorCode rval = MB_SUCCESS;
if (meshset) {
rval = get_meshset_options(meshset, options);MB_CHK_ERR(rval);
rval = get_meshset_options(meshset, setoptions);MB_CHK_ERR(rval);
}
if (!meshset || (options & MESHSET_SET))
if (!meshset || (setoptions & MESHSET_SET))
set_iter = new (std::nothrow) RangeSetIterator(this, meshset, chunk_size, ent_type, ent_dim, check_valid);
else
set_iter = new (std::nothrow) VectorSetIterator(this, meshset, chunk_size, ent_type, ent_dim, check_valid);
......
/*
* CoreOptions.hpp
*/
#ifndef COREOPTIONS_HPP_
#define COREOPTIONS_HPP_
namespace moab
{
class CoreOptions
{
public:
CoreOptions(double s) : option_seq(s) {};
double get_sequence_option() {return option_seq;}
void set_sequence_option(double factor) { option_seq = factor;}
private:
double option_seq;
};
extern CoreOptions coreopts;
}
#endif /* COREOPTIONS_HPP_ */
......@@ -51,7 +51,6 @@ libMOAB_la_SOURCES = \
CN.cpp \
CartVect.cpp \
Core.cpp \
CoreOptions.hpp \
DebugOutput.cpp \
DebugOutput.hpp \
DenseTag.hpp \
......
......@@ -13,7 +13,7 @@
namespace moab {
inline
static ErrorCode not_root_set(const std::string& name, EntityHandle h)
static ErrorCode not_root_set(const std::string& /*name*/, EntityHandle /*h*/)
{
// MB_TAG_NOT_FOUND could be a non-error condition, do not call MB_SET_ERR on it
// Print warning messages for debugging only
......
......@@ -9,7 +9,6 @@
#include "PolyElementSeq.hpp"
#include "SysUtil.hpp"
#include "moab/Error.hpp"
#include "CoreOptions.hpp"
#include <assert.h>
#include <new>
......@@ -43,6 +42,9 @@ SequenceManager::~SequenceManager()
void SequenceManager::clear()
{
// reset sequence multiplier
sequence_multiplier = 1.0;
// Destroy all TypeSequenceManager instances
for (EntityType t = MBVERTEX; t < MBMAXTYPE; ++t)
typeData[t].~TypeSequenceManager();
......@@ -417,7 +419,7 @@ EntityID SequenceManager::new_sequence_size(EntityHandle start,
int sequence_size) const
{
requested_size = (EntityID) (coreopts.get_sequence_option()*requested_size);
requested_size = (EntityID) (this->sequence_multiplier*requested_size);
if (sequence_size < (int)requested_size)
return requested_size;
......
......@@ -14,6 +14,9 @@ class SequenceManager
{
public:
SequenceManager(double default_seq_multiplier = 1.0) : sequence_multiplier(default_seq_multiplier)
{ }
~SequenceManager();
/** Delete all contained data */
......@@ -272,6 +275,28 @@ class SequenceManager
EntityID new_sequence_size( EntityHandle start_handle,
EntityID requested_size,
int sequence_size) const;
/** \brief Interface to control memory allocation for sequences
* Provide a factor that controls the size of the sequence that gets allocated.
* This is typically useful in the parallel setting when a-priori, the number of ghost entities
* and the memory required for them within the same sequence as the owned entities are unknown.
* The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
* have broken sequences.
*/
double get_sequence_multiplier() const
{ return sequence_multiplier; }
/** \brief Interface to control memory allocation for sequences
* Provide a factor that controls the size of the sequence that gets allocated.
* This is typically useful in the parallel setting when a-priori, the number of ghost entities
* and the memory required for them within the same sequence as the owned entities are unknown.
* The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
* have broken sequences.
*
* \param meshset User specified multiplier (should be greater than 1.0)
*/
void set_sequence_multiplier(double factor)
{ sequence_multiplier = factor; }
/**\brief Default allocation size for vertices */
static const EntityID DEFAULT_VERTEX_SEQUENCE_SIZE;
......@@ -321,6 +346,9 @@ class SequenceManager
std::vector<int> tagSizes;
/**\brief The over-allocation factor for entities in a sequence (strictly >= 1.0) */
double sequence_multiplier;
};
} // namespace moab
......
......@@ -1091,7 +1091,7 @@ public:
virtual ErrorCode remove_child_meshset(EntityHandle meshset,
const EntityHandle child_meshset);
// ************************ error condition information ***************
// ************************ tag information ***************
//! return various specific tag handles
Tag material_tag();
......@@ -1108,6 +1108,8 @@ public:
//int total_num_elements() const;
//void total_num_elements(const int val);
// ************************ structured sequence information ***************
//! return a reference to the sequence manager
SequenceManager* sequence_manager() { return sequenceManager; }
const SequenceManager* sequence_manager() const { return sequenceManager; }
......@@ -1290,6 +1292,33 @@ public:
void print_database() const;
/** \name Sequence Option controllers */
/**@{*/
/** \brief Interface to control memory allocation for sequences
* Provide a factor that controls the size of the sequence that gets allocated.
* This is typically useful in the parallel setting when a-priori, the number of ghost entities
* and the memory required for them within the same sequence as the owned entities are unknown.
* The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
* have broken sequences.
*/
virtual double get_sequence_multiplier() const;
/** \brief Interface to control memory allocation for sequences
* Provide a factor that controls the size of the sequence that gets allocated.
* This is typically useful in the parallel setting when a-priori, the number of ghost entities
* and the memory required for them within the same sequence as the owned entities are unknown.
* The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
* have broken sequences.
*
* \param meshset User specified multiplier (should be greater than 1.0)
*/
virtual void set_sequence_multiplier(double factor);
/**@}*/
private:
/**\brief Do not allow copying */
......
......@@ -1985,6 +1985,37 @@ public:
SetIterator *&set_iter) = 0;
/**@}*/
// ************************ Interface options controllable by user ***************
/** \name Sequence Option controllers */
/**@{*/
/** \brief Interface to control memory allocation for sequences
* Provide a factor that controls the size of the sequence that gets allocated.
* This is typically useful in the parallel setting when a-priori, the number of ghost entities
* and the memory required for them within the same sequence as the owned entities are unknown.
* The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
* have broken sequences.
*/
virtual double get_sequence_multiplier() const = 0;
/** \brief Interface to control memory allocation for sequences
* Provide a factor that controls the size of the sequence that gets allocated.
* This is typically useful in the parallel setting when a-priori, the number of ghost entities
* and the memory required for them within the same sequence as the owned entities are unknown.
* The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
* have broken sequences.
*
* \param meshset User specified multiplier (should be greater than 1.0)
*/
virtual void set_sequence_multiplier(double factor) = 0;
/**@}*/
};
//! predicate for STL algorithms. Returns true if the entity handle is
......
......@@ -7,7 +7,6 @@
#include "moab/ReadUtilIface.hpp"
#include "moab/ParallelComm.hpp"
#include "MBParallelConventions.h"
#include "CoreOptions.hpp"
#include <iostream>
#include <iomanip>
......@@ -181,7 +180,7 @@ ErrorCode ReadParallel::load_file(const char **file_names,
{
if (factor_seq<1.)
MB_SET_ERR(MB_FAILURE, "cannot have sequence factor less than 1.");
coreopts.set_sequence_option(factor_seq);
mbImpl->set_sequence_multiplier(factor_seq);
}
switch (parallel_mode) {
case POPT_BCAST:
......
......@@ -137,6 +137,9 @@ ErrorCode test_delete_entities(const char *);
ErrorCode test_ghost_polyhedra(const char *);
// Test failed read with too few parts in partition
ErrorCode test_too_few_parts(const char *);
// Test broken sequences due to ghosting
ErrorCode test_sequences_after_ghosting(const char *);
/**************************************************************************
Main Method
......@@ -237,6 +240,7 @@ int main( int argc, char* argv[] )
num_errors += RUN_TEST( test_ghost_tag_exchange, filename );
num_errors += RUN_TEST( regression_ghost_tag_exchange_no_default, filename );
num_errors += RUN_TEST( test_delete_entities, filename2);
num_errors += RUN_TEST (test_sequences_after_ghosting, filename2) ;
if (2>=size) // run this one only on one or 2 processors; the file has only 2 parts in partition
num_errors += RUN_TEST( test_ghost_polyhedra, filename3);
if (2==size)
......@@ -1737,3 +1741,75 @@ ErrorCode test_too_few_parts( const char* filename )
return MB_SUCCESS;
}
ErrorCode test_sequences_after_ghosting( const char* filename )
{
Core mb_instance;
Interface& moab = mb_instance;
ErrorCode rval;
rval = moab.load_file( filename, 0,
"PARALLEL=READ_PART;"
"PARTITION=PARALLEL_PARTITION;"
"PARALLEL_RESOLVE_SHARED_ENTS;"
"PARALLEL_GHOSTS=3.2.1;"
"PARALLEL_SEQUENCE_FACTOR=1.5" );
CHKERR(rval);
// get all elements of dimension 3, and check they are on one sequence, with connect_iterate
Range elems;
rval = moab.get_entities_by_dimension(0, 3, elems);CHKERR(rval);
if (elems.psize()!=1)
{
std::cout << " elems.psize() = " << elems.psize() << "\n";
return MB_FAILURE;
}
// we want only one sequence
int count, vpere;
EntityHandle *conn_ptr;
rval = moab.connect_iterate(elems.begin(), elems.end(), conn_ptr, vpere, count ); CHKERR(rval);
if (count != (int) elems.size() )
{
std::cout << " more than one sequence: elems.size() = " << elems.size() << " count:" << count << "\n";
return MB_FAILURE;
}
// check also global id tag, which is dense
Tag id_tag;
rval = moab.tag_get_handle( GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, id_tag ); CHKERR(rval);
void * globalid_data= NULL;
rval = moab.tag_iterate( id_tag, elems.begin(), elems.end(), count, globalid_data); CHKERR(rval);
if (count != (int) elems.size() )
{
std::cout << " more than one tag sequence: elems.size() = " << elems.size() << " count:" << count << "\n";
return MB_FAILURE;
}
// repeat the tests for vertex sequences
// get all elements of dimension 3, and check they are on one sequence, with coords_iterate
Range verts;
rval = moab.get_entities_by_dimension(0, 0, verts);CHKERR(rval);
if (verts.psize()!=1)
{
std::cout << " verts.psize() = " << verts.psize() << "\n";
return MB_FAILURE;
}
//
double *x_ptr, *y_ptr, *z_ptr;
rval = moab.coords_iterate(verts.begin(), verts.end(), x_ptr, y_ptr, z_ptr, count); CHKERR(rval);
if (count != (int) verts.size() )
{
std::cout << " more than one sequence: verts.size() = " << verts.size() << " count:" << count << "\n";
return MB_FAILURE;
}
rval = moab.tag_iterate( id_tag, verts.begin(), verts.end(), count, globalid_data); CHKERR(rval);
if (count != (int) verts.size() )
{
std::cout << " more than one tag sequence: verts.size() = " << verts.size() << " count:" << count << "\n";
return MB_FAILURE;
}
return MB_SUCCESS;
}
......@@ -43,6 +43,7 @@ int main(int argc, char **argv)
po.addOpt<int>( "leaf,l", "Number of doublings of maximum number of elements per leaf", &dleafs);
po.addOpt<int>( "max_depth,m", "Number of 5-intervals on maximum depth of tree", &ddeps);
po.addOpt<int>( "npoints,n", "Number of query points", &npoints);
po.addOpt<int>( "dim,d", "Dimension of the mesh", &dim);
po.addOpt<double>( "tol,t", "Relative tolerance of point search", &rtol);
// po.addOpt<void>( "print,p", "Print tree details", &print_tree);
po.parseCommandLine(argc, argv);
......@@ -73,7 +74,7 @@ int main(int argc, char **argv)
for (std::vector<int>::iterator int_it = ints.begin(); int_it != ints.end(); ++int_it) {
Core mb;
Range elems;
rval = create_hex_mesh(mb, elems, *int_it, 3);
rval = create_hex_mesh(mb, elems, *int_it, dim);
if (MB_SUCCESS != rval) return rval;
// iteration: tree depth
......
......@@ -40,6 +40,7 @@ int main(int argc, char **argv)
po.addOpt<int>( "leaf,l", "Number of doublings of maximum number of elements per leaf", &dleafs);
po.addOpt<int>( "max_depth,m", "Number of 5-intervals on maximum depth of tree", &ddeps);
po.addOpt<int>( "npoints,n", "Number of query points", &npoints);
po.addOpt<int>( "dim,d", "Dimension of the mesh", &dim);
// po.addOpt<void>( "print,p", "Print tree details", &print_tree);
po.parseCommandLine(argc, argv);
......@@ -69,7 +70,7 @@ int main(int argc, char **argv)
for (std::vector<int>::iterator int_it = ints.begin(); int_it != ints.end(); ++int_it) {
Core mb;
Range elems;
rval = create_hex_mesh(mb, elems, *int_it, 3);
rval = create_hex_mesh(mb, elems, *int_it, dim);
if (MB_SUCCESS != rval) return rval;
// iteration: tree depth
......
......@@ -107,7 +107,7 @@ int main()
err = iface0->delete_entities(to_delete);
err = iface1->delete_entities(to_delete);
for(int qq = 0;qq!=conn_seq.size()/4;qq++) {
for(unsigned qq = 0;qq!=conn_seq.size()/4;qq++) {
EntityHandle q0,q1;
err = iface1->create_element(MBTET,&conn_seq[4*qq],4,q1);CHECK_ERR(err);
err = iface0->create_element(MBTET,&conn_seq[4*qq],4,q0);CHECK_ERR(err);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment