void Foam::fvMeshTools::setPatchFields
(
    typename GeoField::Mesh& mesh,
    const label patchi,
    const dictionary& patchFieldDict
)
{
    objectRegistry& obr = const_cast<objectRegistry&>(mesh.thisDb());

    HashTable<GeoField*> flds(obr.lookupClass<GeoField>());

    forAllIter(typename HashTable<GeoField*>, flds, iter)
    {
        GeoField& fld = *iter();

        typename GeoField::Boundary& bfld =
            fld.boundaryFieldRef();

        if (patchFieldDict.found(fld.name()))
        {
            bfld.set
            (
                patchi,
                GeoField::Patch::New
                (
                    mesh.boundary()[patchi],
                    fld(),
                    patchFieldDict.subDict(fld.name())
                )
            );
        }
    }
}
Exemple #2
0
bool hsclient::query(const char* oper, const char* values[], int num,
	const char* limit_offset, char mop,
	const char* to_values[], int to_num)
{
	acl_assert(tbl_curr_);

	bool retried = false;

	while (true)
	{
		// 创建请求数据
		hsproto::build_request(buf_, tbl_curr_->id_, oper, values,
			num, limit_offset, mop, to_values, to_num);

		if (debugOn_)
			printf("%s(%d)>>>send: (%s)\n",
				__FUNCTION__, __LINE__, buf_.c_str());

		// 与数据库通信并从数据库获得结果
		if (chat() == true)
			break;

		// 如果与数据库通信失败当允许重试时若重试也失败则返回错误
		if (retry_enable_ == false || retried)
		{
			close_stream();
			return (false);
		}

		retried = true;

		// 先缓冲当前表结构中的信息
		string dbn(tbl_curr_->dbn_), tbl(tbl_curr_->tbl_);
		string idx(tbl_curr_->idx_), flds(tbl_curr_->flds_);

		// 先关闭旧的连接对象及所有的表对象
		close_stream();

		// 再重新打开连接对象并打开表对象
		if (open_tbl(dbn.c_str(), tbl.c_str(), idx.c_str(),
				flds.c_str(), true) == false)
		{
			logger_error("reopen error");
			return (false);
		}
	}

	if (debugOn_)
		printf("%s(%d): gets: (%s)\n",
			__FUNCTION__, __LINE__, buf_.c_str());
	return (proto_.parse_respond(tbl_curr_->nfld_, buf_, error_, serror_));
}
void Foam::fvMeshTools::addPatchFields
(
    objectRegistry& obr,
    const dictionary& patchFieldDict,
    const word& defaultPatchFieldType,
    const typename GeoField::value_type& defaultPatchValue
)
{
    HashTable<GeoField*> flds(obr.lookupClass<GeoField>());

    const wordList fldNames(flds.sortedToc());

    forAll(fldNames, i)
    {
        GeoField& fld = *flds[fldNames[i]];

        typename GeoField::Boundary& bfld =
            fld.boundaryFieldRef();

        label sz = bfld.size();
        bfld.setSize(sz+1);

        if (patchFieldDict.found(fld.name()))
        {
            bfld.set
            (
                sz,
                GeoField::Patch::New
                (
                    fld.mesh().boundary()[sz],
                    fld(),
                    patchFieldDict.subDict(fld.name())
                )
            );
        }
        else
        {
            bfld.set
            (
                sz,
                GeoField::Patch::New
                (
                    defaultPatchFieldType,
                    fld.mesh().boundary()[sz],
                    fld()
                )
            );
            bfld[sz] == defaultPatchValue;
        }
    }
void Foam::fvMeshTools::setPatchFields
(
    typename GeoField::Mesh& mesh,
    const label patchi,
    const typename GeoField::value_type& value
)
{
    objectRegistry& obr = const_cast<objectRegistry&>(mesh.thisDb());

    HashTable<GeoField*> flds(obr.lookupClass<GeoField>());

    forAllIter(typename HashTable<GeoField*>, flds, iter)
    {
        GeoField& fld = *iter();

        typename GeoField::Boundary& bfld =
            fld.boundaryFieldRef();

        bfld[patchi] == value;
    }
}
void Foam::nearWallFields::createFields
(
    PtrList<GeometricField<Type, fvPatchField, volMesh> >& sflds
) const
{
    typedef GeometricField<Type, fvPatchField, volMesh> vfType;

    HashTable<const vfType*> flds(obr_.lookupClass<vfType>());

    forAllConstIter(typename HashTable<const vfType*>, flds, iter)
    {
        const vfType& fld = *iter();

        if (fieldMap_.found(fld.name()))
        {
            const word& sampleFldName = fieldMap_[fld.name()];

            if (obr_.found(sampleFldName))
            {
                Info<< "    a field " << sampleFldName
                    << " already exists on the mesh."
                    << endl;
            }
            else
            {
                label sz = sflds.size();
                sflds.setSize(sz+1);

                IOobject io(fld);
                io.readOpt() = IOobject::NO_READ;
                io.rename(sampleFldName);

                sflds.set(sz, new vfType(io, fld));
                vfType& sampleFld = sflds[sz];

                // Reset the bcs to be directMapped
                forAllConstIter(labelHashSet, patchSet_, iter)
                {
                    label patchI = iter.key();

                    sampleFld.boundaryField().set
                    (
                        patchI,
                        new selfContainedDirectMappedFixedValueFvPatchField
                            <Type>
                        (
                            sampleFld.mesh().boundary()[patchI],
                            sampleFld.dimensionedInternalField(),

                            sampleFld.mesh().name(),
                            directMappedPatchBase::NEARESTCELL,
                            word::null,     // samplePatch
                            -distance_,

                            sampleFld.name(),       // fieldName
                            false,                  // setAverage
                            pTraits<Type>::zero,    // average
                            interpolationCellPoint<Type>::typeName
                        )
                    );
                }

                Info<< "    created " << sampleFld.name() << " to sample "
                    << fld.name() << endl;
            }
        }
    }