Foam::porousZone::porousZone ( const keyType& key, const fvMesh& mesh, const dictionary& dict ) : key_(key), mesh_(mesh), dict_(dict), cellZoneIds_(mesh_.cellZones().findIndices(key_)), coordSys_(dict, mesh), porosity_(1), intensity_(0), mixingLength_(0), C0_(0), C1_(0), D_("D", dimensionSet(0, -2, 0, 0, 0), tensor::zero), F_("F", dimensionSet(0, -1, 0, 0, 0), tensor::zero) { Info<< "Creating porous zone: " << key_ << endl; bool foundZone = !cellZoneIds_.empty(); reduce(foundZone, orOp<bool>()); if (!foundZone && Pstream::master()) { FatalErrorIn ( "Foam::porousZone::porousZone" "(const keyType&, const fvMesh&, const dictionary&)" ) << "cannot find porous cellZone " << key_ << exit(FatalError); } // porosity if ( dict_.readIfPresent("porosity", porosity_) && (porosity_ <= 0.0 || porosity_ > 1.0) ) { FatalIOErrorIn ( "Foam::porousZone::porousZone" "(const keyType&, const fvMesh&, const dictionary&)", dict_ ) << "out-of-range porosity value " << porosity_ << exit(FatalIOError); } // turbulent intensity if ( dict_.readIfPresent("intensity", intensity_) && (intensity_ <= 0.0 || intensity_ > 1.0) ) { FatalIOErrorIn ( "Foam::porousZone::porousZone" "(const keyType&, const fvMesh&, const dictionary&)", dict_ ) << "out-of-range turbulent intensity value " << intensity_ << exit(FatalIOError); } // turbulent length scale if ( dict_.readIfPresent("mixingLength", mixingLength_) && (mixingLength_ <= 0.0) ) { FatalIOErrorIn ( "Foam::porousZone::porousZone" "(const keyType&, const fvMesh&, const dictionary&)", dict_ ) << "out-of-range turbulent length scale " << mixingLength_ << exit(FatalIOError); } // powerLaw coefficients if (const dictionary* dictPtr = dict_.subDictPtr("powerLaw")) { dictPtr->readIfPresent("C0", C0_); dictPtr->readIfPresent("C1", C1_); } // Darcy-Forchheimer coefficients if (const dictionary* dictPtr = dict_.subDictPtr("Darcy")) { // local-to-global transformation tensor const tensor& E = coordSys_.R(); dimensionedVector d(vector::zero); if (dictPtr->readIfPresent("d", d)) { if (D_.dimensions() != d.dimensions()) { FatalIOErrorIn ( "Foam::porousZone::porousZone" "(const keyType&, const fvMesh&, const dictionary&)", dict_ ) << "incorrect dimensions for d: " << d.dimensions() << " should be " << D_.dimensions() << exit(FatalIOError); } adjustNegativeResistance(d); D_.value().xx() = d.value().x(); D_.value().yy() = d.value().y(); D_.value().zz() = d.value().z(); D_.value() = (E & D_ & E.T()).value(); } dimensionedVector f(vector::zero); if (dictPtr->readIfPresent("f", f)) { if (F_.dimensions() != f.dimensions()) { FatalIOErrorIn ( "Foam::porousZone::porousZone" "(const keyType&, const fvMesh&, const dictionary&)", dict_ ) << "incorrect dimensions for f: " << f.dimensions() << " should be " << F_.dimensions() << exit(FatalIOError); } adjustNegativeResistance(f); // leading 0.5 is from 1/2 * rho F_.value().xx() = 0.5*f.value().x(); F_.value().yy() = 0.5*f.value().y(); F_.value().zz() = 0.5*f.value().z(); F_.value() = (E & F_ & E.T()).value(); } } // it is an error not to define anything if ( C0_ <= VSMALL && magSqr(D_.value()) <= VSMALL && magSqr(F_.value()) <= VSMALL ) { FatalIOErrorIn ( "Foam::porousZone::porousZone" "(const keyType&, const fvMesh&, const dictionary&)", dict_ ) << "neither powerLaw (C0/C1) " "nor Darcy-Forchheimer law (d/f) specified" << exit(FatalIOError); } // feedback for the user if (dict.lookupOrDefault("printCoeffs", false)) { writeDict(Info, false); } }
int main(int argc, char *argv[]) { FILE *fin, *fout; char buffer[1024], *data, *cptr, **wlist; /*char *fixlist[] = {"(2)", "(3)", "(4)", "(5)", "(6)", "(7)"};*/ long end, no; if(argc < 3) { printf("Usage: htkdictsort indict outdict\n"); return -1; } fin = fopen(argv[1],"r"); if(!fin) { printf("Error : Unable to open %s\n", argv[1]); return -2; } fseek(fin, 0L, SEEK_END); end = ftell(fin); rewind(fin); data = malloc(((long)sizeof(char))*end+1024L); if(!data) { printf("Unable to load file into memory\n"); return -3; } fread(data, sizeof(char), end, fin); data[end+1L] = EOF; fclose(fin); no = 0L; cptr = data; while(*cptr != EOF) if(*cptr++ == '\n') no++; wlist = calloc(no, sizeof(char *)); /*fixwords(data, fixlist, 6L);*/ setWords(data, wlist, no); /*for(end = 0L; end < no; end++) printf("%s\n", wlist[end]);*/ qsort(&wlist[0], no, sizeof(char *), cmpstringp); /*for(end = 0L; end < no; end++) printf("%s\n", wlist[end]);*/ fout = fopen(argv[2], "w"); if(!fin) { printf("Error : Unable to open %s\n", argv[1]); return -2; } writeDict(data, wlist, no, fout); free(data); free(wlist); fclose(fout); return 0; }
void Foam::surfZone::write(Ostream& os) const { writeDict(os); }