コード例 #1
0
ファイル: HDF5DataWriter.cpp プロジェクト: csiki/MOOSE
void HDF5DataWriter::recvData(const Eref&e, 
				ObjId src, const double* start, unsigned int num )
{
    string path = src.path();
    if (nodemap_.find(path) == nodemap_.end()){
        // first time call, initialize entries in map
        hid_t dataid =  get_dataset(path);
        if (dataid < 0){
            cerr << "Warning: could not create data set for " << path << endl;
        }
        nodemap_[path] = dataid;
        datamap_[path] = vector<double>();
    }
    const double * end = start + num;
    // append only the new data. old_size is guaranteed to be 0 on
    // write and the table vecs will also be cleared.
    datamap_[path].insert(datamap_[path].end(), start, end);

    SetGet0::set(src, "clearVec"); //Unsure what this is for.
	
// #ifndef NDEBUG
//     // debug leftover entries coming from table
//     cout << "HDF5DataWriter::recvData: vec_size=" << vec_size << endl;
//     cout << "HDF5DataWriter::recvData: dataSize=" << pb.dataSize() << endl;
//     cout << "HDF5DataWriter::recvData: numEntries=" << pb.numEntries()  << endl;
//     cout << "HDF5DataWriter::recvData: size=" << pb.size() << endl;
//     cout << "HDF5DataWriter::recvData: data()" << endl;
//     for (int ii = 0; ii <= vec_size; ++ii){
//         cout << ii << "\t" << pb.data()[ii] << endl;
//     }
// #endif
}
コード例 #2
0
ファイル: Shell.cpp プロジェクト: iampritishpatil/moose
void Shell::doMove( Id orig, ObjId newParent )
{
	if ( orig == Id() ) {
		cout << "Error: Shell::doMove: Cannot move root Element\n";
		return;
	}

	if ( newParent.element() == 0 ) {
		cout << "Error: Shell::doMove: Cannot move object to null parent \n";
		return;
	}
	if ( Neutral::isDescendant( newParent, orig ) ) {
		cout << "Error: Shell::doMove: Cannot move object to descendant in tree\n";
		return;
		
	}
	const string& name = orig.element()->getName();
	if ( Neutral::child( newParent.eref(), name ) != Id() ) {
			stringstream ss;
			ss << "Shell::doMove: Object with same name already present: '"
			   	<< newParent.path() << "/" << name << "'. Move failed.";
			warning( ss.str() );
			return;
	}

	SetGet2< Id, ObjId >::set( ObjId(), "move", orig, newParent );
	// innerMove( orig, newParent );
}
コード例 #3
0
ファイル: EndoMesh.cpp プロジェクト: hrani/moose-core
void EndoMesh::setSurround( const Eref& e, ObjId v )
{
	if ( !v.element()->cinfo()->isA( "ChemCompt" ) ) {
		cout << "Warning: 'surround' may only be set to an object of class 'ChemCompt'\n";
		cout << v.path() << " is of class " << v.element()->cinfo()->name() << endl;
		return;
	}
	surround_ = v;
	parent_ = reinterpret_cast< const MeshCompt* >( v.data() );
}
コード例 #4
0
ファイル: Shell.cpp プロジェクト: iampritishpatil/moose
/**
 * This is the version used by the parser. Acts as a blocking,
 * serial-like interface to a potentially multithread, multinode call.
 * Returns the new Id index upon success, otherwise returns Id().
 * The data of the new Element is not necessarily allocated at this point,
 * that can be deferred till the global Instantiate or Reset calls.
 * Idea is that the model should be fully defined before load balancing.
 *
 */
Id Shell::doCreate( string type, ObjId parent, string name, 
				unsigned int numData, 
				NodePolicy nodePolicy,
				unsigned int preferredNode )
{
#ifdef ENABLE_LOGGER
    clock_t t = clock();
#endif
	const Cinfo* c = Cinfo::find( type );
	if ( !isNameValid( name ) ) {
		stringstream ss;
		ss << "Shell::doCreate: bad character in name'" << name << 
				"'. No Element created";
		warning( ss.str() );
		return Id();
	}

	if ( c ) {
		if ( c->banCreation() ) {
			stringstream ss;
			ss << "Shell::doCreate: Cannot create an object of class '" <<
				type << "' because it is an abstract base class or a FieldElement.\n";
			warning( ss.str() );
			return Id();
		}
		Element* pa = parent.element();
		if ( !pa ) {
			stringstream ss;
			ss << "Shell::doCreate: Parent Element'" << parent << "' not found. No Element created";
			warning( ss.str() );
			return Id();
		}
		if ( Neutral::child( parent.eref(), name ) != Id() ) {
			stringstream ss;
			ss << "Shell::doCreate: Object with same name already present: '"
				   	<< parent.path() << "/" << name << "'. No Element created";
			warning( ss.str() );
			return Id();
		}
		// Get the new Id ahead of time and pass to all nodes.
		Id ret = Id::nextId();
		NodeBalance nb( numData, nodePolicy, preferredNode );
		// Get the parent MsgIndex ahead of time and pass to all nodes.
		unsigned int parentMsgIndex = OneToAllMsg::numMsg();

		SetGet6< string, ObjId, Id, string, NodeBalance, unsigned int >::set(
			ObjId(), // Apply command to Shell
			"create",	// Function to call.
			type, 		// class of new object
			parent,		// Parent
			ret,		// id of new object
			name,		// name of new object
			nb,			// Node balance configuration
			parentMsgIndex	// Message index of child-parent msg.
		);
		// innerCreate( type, parent, ret, name, numData, isGlobal );

#ifdef ENABLE_LOGGER 
        logger.creationTime.push_back((float(clock() - t)/CLOCKS_PER_SEC));
#endif

		return ret;
	} else {
		stringstream ss;
		ss << "Shell::doCreate: Class '" << type << "' not known. No Element created";
		warning( ss.str() );
	}

#ifdef ENABLE_LOGGER 
        logger.creationTime.push_back((float(clock() - t)/CLOCKS_PER_SEC));
#endif
	return Id();
}