void Foam::myVelocityFvPatchVectorField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

    // Variablen/ Felder
    const volVectorField& u = db().lookupObject<volVectorField>("u");
    //fvPatchVectorField& u_b = *this;
    tmp<vectorField> tu_b = *this;
    vectorField& u_b = tu_b();

    const tmp<vectorField> tn = this->patch().nf();
    const vectorField& n = tn();

    tmp<volTensorField> tGradU = fvc::grad(u);
    const volTensorField gradU = tGradU();
    tmp<vectorField> tD = patch().delta();
    const vectorField& D = tD();
    const labelList& bcs = patch().faceCells();

    for(int i=0; i<patch().size(); i++) {

        const label bc = bcs[i];
        const vector normal = n[i];
        const tensor Jac_u = gradU[bc];
        const vector u_bc = u[bc];
        const vector Di = D[i];

        vector u_b_extrapolated;

        u_b_extrapolated.component(0) = u_bc.component(0) +
                                        Jac_u.component(tensor::XX) * Di.component(0) +
                                        Jac_u.component(tensor::XY) * Di.component(1) +
                                        Jac_u.component(tensor::XZ) * Di.component(2);

        u_b_extrapolated.component(1) = u_bc.component(1) +
                                        Jac_u.component(tensor::YX) * Di.component(0) +
                                        Jac_u.component(tensor::YY) * Di.component(1) +
                                        Jac_u.component(tensor::YZ) * Di.component(2);

        u_b_extrapolated.component(2) = u_bc.component(2) +
                                        Jac_u.component(tensor::ZX) * Di.component(0) +
                                        Jac_u.component(tensor::ZY) * Di.component(1) +
                                        Jac_u.component(tensor::ZZ) * Di.component(2);

        u_b[i] = u_b_extrapolated - (u_b_extrapolated & normal) * normal;

    }

    //Info << u_b << endl;

    fixedValueFvPatchVectorField::updateCoeffs();     // updated_ = true

}
示例#2
0
文件: dblite.cpp 项目: sirmax1/coin
void KVStorage::Vacuum() {
	String tmpPath = Path::GetTempFileName(Path::GetDirectoryName(FilePath), "tmp").first;
	lock_guard<mutex> lkWrite(MtxWrite);
	unique_lock<shared_mutex> lk(ShMtx, defer_lock);
	try {
		KVStorage dbNew;
		dbNew.ProtectPages = false;
		dbNew.AppName = AppName;
		dbNew.UserVersion = UserVersion;
		dbNew.FrontEndName = FrontEndName;
		dbNew.FrontEndVersion = FrontEndVersion;
		
		dbNew.Create(tmpPath);
		{
			DbTransaction txS(_self, true), txD(dbNew);
			txD.Bulk = true;

			int nProgress = m_stepProgress;

			for (DbCursor ct(txS, DbTable::Main); ct.SeekToNext();) {
				String tableName = Encoding::UTF8.GetChars(ct.Key);
				const TableData& td = *(const TableData*)ct.get_Data().P;

				DbTable tS(tableName), tD(tableName);
				tD.KeySize = td.KeySize;
				tD.Open(txD, true);
				int n = 0;
				Int64 bytes = 0;
				for (DbCursor c(txS, tS); c.SeekToNext();) {
					tD.Put(txD, c.Key, c.Data);
					if (m_pfnProgress && !--nProgress) {
						if (m_pfnProgress(m_ctxProgress))
							Throw(HRESULT_FROM_WIN32(ERROR_CANCELLED));
						nProgress = m_stepProgress;
					}
					++n;
					bytes += c.get_Data().Size;
				}
				TRC(2, "Table: " << tableName << ":\t" << n << " records\t" << bytes << " bytes");
			}
			txD.Commit();
		}
		lk.lock();
		Close(false);
	} catch (RCExc) {
		File::Delete(tmpPath);
		throw;
	}
	String tmpOriginal = FilePath+".bak";
	File::Move(FilePath, tmpOriginal);
	File::Move(tmpPath, FilePath);
	File::Delete(tmpOriginal);
	Open(FilePath);
}
void Foam::myVelocityFvPatchVectorField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

    // Variablen/ Felder
    const volVectorField& u = db().lookupObject<volVectorField>("u");
    const volVectorField& uOld = u.oldTime();
    tmp<vectorField> tu_b = *this;
    vectorField& u_b = tu_b();

    const tmp<vectorField> tn = this->patch().nf();
    const vectorField& n = tn();

    tmp<volTensorField> tGradU = fvc::grad(u);
    const volTensorField gradU = tGradU();
    tmp<vectorField> tD = patch().delta();
    const vectorField& D = tD();
    const labelList& bcs = patch().faceCells();

    for(int i=0; i<patch().size(); i++){

        const label bc = bcs[i];
        const vector normal = n[i];
        const tensor Jac_u = gradU[bc];
        const vector u_bc = u[bc];
        const vector Di = D[i];

        vector u_b_extrapolated = u_bc + (Jac_u & Di);

        u_b[i] = u_b_extrapolated - (u_b_extrapolated & normal) * normal;

    }

    fixedValueFvPatchVectorField::updateCoeffs();     // updated_ = true

}