Merge branch 'master' into cvm

This commit is contained in:
graham
2010-07-29 12:55:19 +01:00
102 changed files with 13972 additions and 13631 deletions

View File

@ -1,6 +1,8 @@
Info<< "Mean pressure:" << p.weightedAverage(mesh.V()).value() << endl; Info<< "Mean pressure:" << p.weightedAverage(mesh.V()).value() << endl;
Info<< "Mean temperature:" << T.weightedAverage(mesh.V()).value() << endl; Info<< "Mean temperature:" << T.weightedAverage(mesh.V()).value() << endl;
Info<< "Mean u':" << (sqrt((2.0/3.0)*turbulence->k()))().weightedAverage(mesh.V()).value() << endl; Info<< "Mean u':"
<< (sqrt((2.0/3.0)*turbulence->k()))().weightedAverage(mesh.V()).value()
<< endl;
logSummaryFile logSummaryFile
<< runTime.theta() << tab << runTime.theta() << tab

View File

@ -1,6 +1,8 @@
Info<< "Mean pressure:" << p.weightedAverage(mesh.V()).value() << endl; Info<< "Mean pressure:" << p.weightedAverage(mesh.V()).value() << endl;
Info<< "Mean temperature:" << T.weightedAverage(mesh.V()).value() << endl; Info<< "Mean temperature:" << T.weightedAverage(mesh.V()).value() << endl;
Info<< "Mean u':" << (sqrt((2.0/3.0)*turbulence->k()))().weightedAverage(mesh.V()).value() << endl; Info<< "Mean u':"
<< (sqrt((2.0/3.0)*turbulence->k()))().weightedAverage(mesh.V()).value()
<< endl;
logSummaryFile logSummaryFile
<< runTime.theta() << tab << runTime.theta() << tab

View File

@ -1,6 +1,8 @@
Info<< "Mean pressure:" << p.weightedAverage(mesh.V()).value() << endl; Info<< "Mean pressure:" << p.weightedAverage(mesh.V()).value() << endl;
Info<< "Mean temperature:" << T.weightedAverage(mesh.V()).value() << endl; Info<< "Mean temperature:" << T.weightedAverage(mesh.V()).value() << endl;
Info<< "Mean u':" << (sqrt((2.0/3.0)*turbulence->k()))().weightedAverage(mesh.V()).value() << endl; Info<< "Mean u':"
<< (sqrt((2.0/3.0)*turbulence->k()))().weightedAverage(mesh.V()).value()
<< endl;
logSummaryFile logSummaryFile
<< runTime.theta() << tab << runTime.theta() << tab

View File

@ -76,7 +76,10 @@
const bool pressureImplicitPorosity = const bool pressureImplicitPorosity =
( (
pZones.size() pZones.size()
&& mesh.solutionDict().subDict("SIMPLE").readIfPresent("nUCorrectors", nUCorr) && mesh.solutionDict().subDict("SIMPLE").readIfPresent
(
"nUCorrectors",
nUCorr
)
&& (nUCorr > 0) && (nUCorr > 0)
); );

View File

@ -1,6 +1,11 @@
surfaceScalarField::GeometricBoundaryField& phiPatches = phi.boundaryField(); surfaceScalarField::GeometricBoundaryField& phiPatches =
const volVectorField::GeometricBoundaryField& rhoUpatches = rhoU.boundaryField(); phi.boundaryField();
const surfaceVectorField::GeometricBoundaryField& SfPatches = mesh.Sf().boundaryField();
const volVectorField::GeometricBoundaryField& rhoUpatches =
rhoU.boundaryField();
const surfaceVectorField::GeometricBoundaryField& SfPatches =
mesh.Sf().boundaryField();
forAll(phiPatches, patchI) forAll(phiPatches, patchI)
{ {

View File

@ -25,9 +25,9 @@ Global
setMultiRegionDeltaT setMultiRegionDeltaT
Description Description
Reset the timestep to maintain a constant maximum courant and diffusion Reset the timestep to maintain a constant maximum courant and
Numbers. Reduction of time-step is immediate, but increase is damped to avoid diffusion Numbers. Reduction of time-step is immediate, but
unstable oscillations. increase is damped to avoid unstable oscillations.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -67,7 +67,13 @@
label paRefCell = 0; label paRefCell = 0;
scalar paRefValue = 0.0; scalar paRefValue = 0.0;
setRefCell(pa, mesh.solutionDict().subDict("SIMPLE"), paRefCell, paRefValue); setRefCell
(
pa,
mesh.solutionDict().subDict("SIMPLE"),
paRefCell,
paRefValue
);
singlePhaseTransportModel laminarTransport(U, phi); singlePhaseTransportModel laminarTransport(U, phi);

View File

@ -59,7 +59,8 @@ if (nWallFaces == 0)
} }
else else
{ {
Info<< "Generating wall data for patch: " << patches[patchId].name() << endl; Info<< "Generating wall data for patch: " << patches[patchId].name()
<< endl;
} }
// store local id of near-walll cell to process // store local id of near-walll cell to process
@ -71,4 +72,3 @@ scalarField y =
& (mesh.C().internalField() - mesh.C().boundaryField()[patchId][faceId]); & (mesh.C().internalField() - mesh.C().boundaryField()[patchId][faceId]);
Info<< " Height to first cell centre y0 = " << y[cellId] << endl; Info<< " Height to first cell centre y0 = " << y[cellId] << endl;

View File

@ -49,7 +49,10 @@
const bool pressureImplicitPorosity = const bool pressureImplicitPorosity =
( (
pZones.size() pZones.size()
&& mesh.solutionDict().subDict("SIMPLE").readIfPresent("nUCorrectors", nUCorr) && mesh.solutionDict().subDict("SIMPLE").readIfPresent
(
"nUCorrectors",
nUCorr
)
&& (nUCorr > 0) && (nUCorr > 0)
); );

View File

@ -34,7 +34,13 @@
betaEqn.relax(); betaEqn.relax();
betaEqn.solve(); betaEqn.solve();
alpha = 0.5*(scalar(1) + sqr(scalar(1) - beta) - sqr(scalar(1) - alpha)); alpha =
0.5
*(
scalar(1)
+ sqr(scalar(1) - beta)
- sqr(scalar(1) - alpha)
);
*/ */
beta = scalar(1) - alpha; beta = scalar(1) - alpha;

View File

@ -32,7 +32,11 @@
phi = alphaf*phia + betaf*phib; phi = alphaf*phia + betaf*phib;
surfaceScalarField Dp("(rho*(1|A(U)))", alphaf*rUaAf/rhoa + betaf*rUbAf/rhob); surfaceScalarField Dp
(
"(rho*(1|A(U)))",
alphaf*rUaAf/rhoa + betaf*rUbAf/rhob
);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{ {

View File

@ -1,6 +1,11 @@
surfaceScalarField::GeometricBoundaryField& phivPatches = phiv.boundaryField(); surfaceScalarField::GeometricBoundaryField& phivPatches =
const volVectorField::GeometricBoundaryField& Upatches = U.boundaryField(); phiv.boundaryField();
const surfaceVectorField::GeometricBoundaryField& SfPatches = mesh.Sf().boundaryField();
const volVectorField::GeometricBoundaryField& Upatches =
U.boundaryField();
const surfaceVectorField::GeometricBoundaryField& SfPatches =
mesh.Sf().boundaryField();
forAll(phivPatches, patchI) forAll(phivPatches, patchI)
{ {

View File

@ -26,7 +26,8 @@
phi = phiU + phi = phiU +
( (
fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() fvc::interpolate(interface.sigmaK())
*fvc::snGrad(alpha1)*mesh.magSf()
+ fvc::interpolate(rho)*(g & mesh.Sf()) + fvc::interpolate(rho)*(g & mesh.Sf())
)*rUAf; )*rUAf;

View File

@ -59,7 +59,17 @@
alpharScheme alpharScheme
); );
MULES::explicitSolve(geometricOneField(), alpha1, phi, phiAlpha1, Sp, Su, 1, 0); MULES::explicitSolve
(
geometricOneField(),
alpha1,
phi,
phiAlpha1,
Sp,
Su,
1,
0
);
surfaceScalarField rho1f = fvc::interpolate(rho1); surfaceScalarField rho1f = fvc::interpolate(rho1);
surfaceScalarField rho2f = fvc::interpolate(rho2); surfaceScalarField rho2f = fvc::interpolate(rho2);

View File

@ -26,7 +26,8 @@
phi = phiU + phi = phiU +
( (
fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() fvc::interpolate(interface.sigmaK())
*fvc::snGrad(alpha1)*mesh.magSf()
+ fvc::interpolate(rho)*(g & mesh.Sf()) + fvc::interpolate(rho)*(g & mesh.Sf())
)*rUAf; )*rUAf;

View File

@ -15,7 +15,8 @@
phi = phiU + phi = phiU +
( (
fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() fvc::interpolate(interface.sigmaK())
*fvc::snGrad(alpha1)*mesh.magSf()
+ fvc::interpolate(rho)*(g & mesh.Sf()) + fvc::interpolate(rho)*(g & mesh.Sf())
)*rUAf; )*rUAf;

View File

@ -50,9 +50,29 @@
+ vDotcAlphal + vDotcAlphal
); );
//MULES::explicitSolve(alpha1, phi, phiAlpha, 1, 0); // MULES::explicitSolve(alpha1, phi, phiAlpha, 1, 0);
//MULES::explicitSolve(geometricOneField(), alpha1, phi, phiAlpha, Sp, Su, 1, 0); // MULES::explicitSolve
MULES::implicitSolve(geometricOneField(), alpha1, phi, phiAlpha, Sp, Su, 1, 0); // (
// geometricOneField(),
// alpha1,
// phi,
// phiAlpha,
// Sp,
// Su,
// 1,
// 0
// );
MULES::implicitSolve
(
geometricOneField(),
alpha1,
phi,
phiAlpha,
Sp,
Su,
1,
0
);
rhoPhi += rhoPhi +=
(runTime.deltaT()/totalDeltaT) (runTime.deltaT()/totalDeltaT)

View File

@ -15,7 +15,8 @@
phi = phiU + phi = phiU +
( (
fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() fvc::interpolate(interface.sigmaK())
*fvc::snGrad(alpha1)*mesh.magSf()
+ fvc::interpolate(rho)*(g & mesh.Sf()) + fvc::interpolate(rho)*(g & mesh.Sf())
)*rUAf; )*rUAf;

View File

@ -45,7 +45,11 @@
phi = alphaf*phia + betaf*phib; phi = alphaf*phia + betaf*phib;
surfaceScalarField Dp("(rho*(1|A(U)))", alphaf*rUaAf/rhoa + betaf*rUbAf/rhob); surfaceScalarField Dp
(
"(rho*(1|A(U)))",
alphaf*rUaAf/rhoa + betaf*rUbAf/rhob
);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{ {

View File

@ -705,17 +705,22 @@ static uint32_t crc_16_table[16] = {
}; };
/* /*
* This code was found at: http://wannabe.guru.org/alg/node191.html * This code was found at: http://wannabe.guru.org/alg/node191.html
* and still exists here: http://www.fearme.com/misc/alg/node191.html * and still exists here: http://www.fearme.com/misc/alg/node191.html
* *
* this source code is based on Rex and Binstock which, in turn, * this source code is based on Rex and Binstock which, in turn,
* acknowledges William James Hunt. * acknowledges William James Hunt.
* *
* According to the site this CRC uses the polynomial x^16+x^5+x^2+1. * According to the site this CRC uses the polynomial x^16+x^5+x^2+1.
* Unfortunately, DOCSIS uses x^16+x^12+x^5+1. D'oh! * Unfortunately, DOCSIS uses x^16+x^12+x^5+1. D'oh!
*/ */
static uint32_t GetCRC16Update (uint32_t start_crc, const char * data_stream, int length) { static uint32_t GetCRC16Update
(
uint32_t start_crc,
const char * data_stream,
int length
) {
uint32_t crc = start_crc; uint32_t crc = start_crc;
uint32_t r; uint32_t r;
@ -740,7 +745,7 @@ uint32_t r;
} }
uint32_t GetCRC16 (const char * data_stream, int length) { uint32_t GetCRC16 (const char * data_stream, int length) {
return GetCRC16Update (0, data_stream, length); return GetCRC16Update (0, data_stream, length);
} }
/* ======================================================================== */ /* ======================================================================== */
@ -794,35 +799,40 @@ static void GenerateCRC32Table (void) {
register int i, j; register int i, j;
register uint32_t crc_accum; register uint32_t crc_accum;
for ( i = 0; i < 256; i++ ) { for ( i = 0; i < 256; i++ ) {
crc_accum = ( (unsigned long) i << 24 ); crc_accum = ( (unsigned long) i << 24 );
for ( j = 0; j < 8; j++ ) { for ( j = 0; j < 8; j++ ) {
if ( crc_accum & 0x80000000L ) { if ( crc_accum & 0x80000000L ) {
crc_accum = ( crc_accum << 1 ) ^ CRC32POLYNOMIAL; crc_accum = ( crc_accum << 1 ) ^ CRC32POLYNOMIAL;
} else { } else {
crc_accum = ( crc_accum << 1 ); crc_accum = ( crc_accum << 1 );
} }
} }
crc_table[i] = crc_accum; crc_table[i] = crc_accum;
} }
return; return;
} }
/* update the CRC on the data block one byte at a time */ /* update the CRC on the data block one byte at a time */
static uint32_t UpdateCRC32 (uint32_t crc_accum, const char *data_blk_ptr, int data_blk_size) { static uint32_t UpdateCRC32
(
uint32_t crc_accum,
const char *data_blk_ptr,
int data_blk_size
) {
register int j; register int j;
register uint8_t i; register uint8_t i;
for (j = 0; j < data_blk_size; j++) { for (j = 0; j < data_blk_size; j++) {
i = (crc_accum >> 24) ^ *data_blk_ptr++; i = (crc_accum >> 24) ^ *data_blk_ptr++;
crc_accum = (crc_accum << 8) ^ crc_table[i]; crc_accum = (crc_accum << 8) ^ crc_table[i];
} }
return crc_accum; return crc_accum;
} }
uint32_t GetCRC32 (const char * data_stream, int length) { uint32_t GetCRC32 (const char * data_stream, int length) {
return UpdateCRC32 (0, data_stream, length); return UpdateCRC32 (0, data_stream, length);
} }
/* ======================================================================== */ /* ======================================================================== */
@ -835,14 +845,14 @@ int j;
uint8_t i0, i1; uint8_t i0, i1;
uint32_t crc_accum0 = 0, crc_accum1 = 0x23456789u; uint32_t crc_accum0 = 0, crc_accum1 = 0x23456789u;
if (data_blk_size & 1) crc_accum0 ^= *data_blk_ptr++; if (data_blk_size & 1) crc_accum0 ^= *data_blk_ptr++;
for (j = 1; j < data_blk_size; j+=2) { for (j = 1; j < data_blk_size; j+=2) {
i0 = ((crc_accum0 >> 24) ^ *data_blk_ptr++); i0 = ((crc_accum0 >> 24) ^ *data_blk_ptr++);
i1 = ((crc_accum1 >> 24) ^ *data_blk_ptr++); i1 = ((crc_accum1 >> 24) ^ *data_blk_ptr++);
crc_accum0 = (crc_accum0 << 8) ^ crc_table[i0]; crc_accum0 = (crc_accum0 << 8) ^ crc_table[i0];
crc_accum1 = (crc_accum1 << 8) ^ crc_table[i1]; crc_accum1 = (crc_accum1 << 8) ^ crc_table[i1];
} }
return crc_accum0 + crc_accum1; return crc_accum0 + crc_accum1;
} }
/* ======================================================================== */ /* ======================================================================== */
@ -855,11 +865,11 @@ uint32_t FNVHash (const char * data, int len) {
int i; int i;
uint32_t hash; uint32_t hash;
hash = 2166136261u; hash = 2166136261u;
for (i=0; i < len; i++) { for (i=0; i < len; i++) {
hash = (16777619u * hash) ^ data[i]; hash = (16777619u * hash) ^ data[i];
} }
return hash; return hash;
} }
/* ======================================================================== */ /* ======================================================================== */
@ -872,15 +882,15 @@ uint32_t oneAtATimeHash (const char * s, int len) {
int32_t hash; int32_t hash;
int i; int i;
for (hash = 0, i = 0; i < len; i++) { for (hash = 0, i = 0; i < len; i++) {
hash += s[i]; hash += s[i];
hash += (hash << 10); hash += (hash << 10);
hash ^= (hash >> 6); /* Non-portable due to ANSI C */ hash ^= (hash >> 6); /* Non-portable due to ANSI C */
} }
hash += (hash << 3); hash += (hash << 3);
hash ^= (hash >> 11); /* Non-portable due to ANSI C */ hash ^= (hash >> 11); /* Non-portable due to ANSI C */
hash += (hash << 15); hash += (hash << 15);
return (uint32_t) hash; return (uint32_t) hash;
} }
/* ======================================================================== */ /* ======================================================================== */
@ -889,23 +899,23 @@ uint32_t oneAtATimeHashPH (const char * s, int len) {
int32_t hash0 = 0, hash1 = 0x23456789; int32_t hash0 = 0, hash1 = 0x23456789;
int i; int i;
if (len & 1) hash1 ^= *s++; if (len & 1) hash1 ^= *s++;
for (i = 1; i < len; i+=2) { for (i = 1; i < len; i+=2) {
hash0 += *s++; hash0 += *s++;
hash1 += *s++; hash1 += *s++;
hash0 += (hash0 << 10); hash0 += (hash0 << 10);
hash1 += (hash1 << 10); hash1 += (hash1 << 10);
hash0 ^= (hash0 >> 6); /* Non-portable due to ANSI C */ hash0 ^= (hash0 >> 6); /* Non-portable due to ANSI C */
hash1 ^= (hash1 >> 6); /* Non-portable due to ANSI C */ hash1 ^= (hash1 >> 6); /* Non-portable due to ANSI C */
} }
hash0 += hash1; hash0 += hash1;
hash0 += (hash0 << 3); hash0 += (hash0 << 3);
hash0 ^= (hash0 >> 11); /* Non-portable due to ANSI C */ hash0 ^= (hash0 >> 11); /* Non-portable due to ANSI C */
hash0 += (hash0 << 15); hash0 += (hash0 << 15);
return (uint32_t) hash0; return (uint32_t) hash0;
} }
/* ======================================================================== */ /* ======================================================================== */
@ -1029,42 +1039,42 @@ static char buff[BUFF_SZ];
clock_t c0, c1; clock_t c0, c1;
int32_t i; int32_t i;
for (buff[0]=0, i=1; i < BUFF_SZ; i++) buff[i] = (char) (i + buff[i-1]); for (buff[0]=0, i=1; i < BUFF_SZ; i++) buff[i] = (char) (i + buff[i-1]);
c0 = clock (); c0 = clock ();
for (i=0; i < NTESTS; i++) hash (buff, BUFF_SZ); for (i=0; i < NTESTS; i++) hash (buff, BUFF_SZ);
c1 = clock (); c1 = clock ();
return (c1 - c0)*(1.0 / (double)CLOCKS_PER_SEC); return (c1 - c0)*(1.0 / (double)CLOCKS_PER_SEC);
} }
struct tagtest { struct tagtest {
double res; double res;
char * name; char * name;
hashFn hash; hashFn hash;
} tests[] = { } tests[] = {
// { 0.0, "CRC32\t\t", GetCRC32 }, // { 0.0, "CRC32\t\t", GetCRC32 },
// { 0.0, "oneAtATimeHash\t", oneAtATimeHash }, // { 0.0, "oneAtATimeHash\t", oneAtATimeHash },
// { 0.0, "alphaNumHash\t", alphaNumHash }, // { 0.0, "alphaNumHash\t", alphaNumHash },
{ 0.0, "FNVHash\t\t", FNVHash }, { 0.0, "FNVHash\t\t", FNVHash },
{ 0.0, "bernstein\t", bernstein }, { 0.0, "bernstein\t", bernstein },
{ 0.0, "stroustrup\t", stroustrup }, { 0.0, "stroustrup\t", stroustrup },
{ 0.0, "hashLookup3\t", hashLookup3 }, { 0.0, "hashLookup3\t", hashLookup3 },
{ 0.0, "hashLookup3Orig\t", hashLookup3Orig }, { 0.0, "hashLookup3Orig\t", hashLookup3Orig },
{ 0.0, "SuperFastHash\t", SuperFastHash }, { 0.0, "SuperFastHash\t", SuperFastHash },
{ 0.0, NULL, NULL } { 0.0, NULL, NULL }
}; };
int main () { int main () {
int i, j; int i, j;
GenerateCRC32Table (); GenerateCRC32Table ();
for (j=0; tests[j].name != NULL; j++) { for (j=0; tests[j].name != NULL; j++) {
for (i=0; i < 3; i++) { for (i=0; i < 3; i++) {
double res = test (tests[j].hash); double res = test (tests[j].hash);
if (tests[j].res == 0.0 || tests[j].res > res) tests[j].res = res; if (tests[j].res == 0.0 || tests[j].res > res) tests[j].res = res;
} }
printf ("%s:%8.4fs\n", tests[j].name, tests[j].res); printf ("%s:%8.4fs\n", tests[j].name, tests[j].res);
} }
return 0; return 0;
} }

View File

@ -53,12 +53,15 @@ inline void reportInfo()
<< " utilization: " << (nBits * offset) << nl; << " utilization: " << (nBits * offset) << nl;
Info<< " Masking:" << nl Info<< " Masking:" << nl
<< " shift << " << unsigned(nBits * offset) << nl << " shift << "
<< " shift >> " << unsigned((sizeof(unsigned)*CHAR_BIT) - nBits * offset) << unsigned(nBits * offset) << nl
<< " shift >> "
<< unsigned((sizeof(unsigned)*CHAR_BIT) - nBits * offset)
<< nl; << nl;
hex(Info); hex(Info);
Info<< " maskLower: " << PackedList<nBits>::maskLower(PackedList<nBits>::packing()) Info<< " maskLower: "
<< PackedList<nBits>::maskLower(PackedList<nBits>::packing())
<< nl << nl
<< " useSHL: " << useSHL << nl << " useSHL: " << useSHL << nl
<< " useSHR: " << useSHR << nl; << " useSHR: " << useSHR << nl;

View File

@ -62,11 +62,13 @@ int main(int argc, char *argv[])
dictionary dict2(dict1.xfer()); dictionary dict2(dict1.xfer());
Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << nl Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << nl
<< "dict2.toc(): " << dict2.name() << " " << dict2.toc() << endl; << "dict2.toc(): " << dict2.name() << " " << dict2.toc()
<< endl;
// copy back // copy back
dict1 = dict2; dict1 = dict2;
Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << endl; Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc()
<< endl;
dictionary dict3(dict2.subDictPtr("boundaryField")); dictionary dict3(dict2.subDictPtr("boundaryField"));
dictionary dict4(dict2.subDictPtr("NONEXISTENT")); dictionary dict4(dict2.subDictPtr("NONEXISTENT"));

View File

@ -29,8 +29,11 @@ int main()
Info<< "tr.transform(v) " << tr.transform(v) << endl; Info<< "tr.transform(v) " << tr.transform(v) << endl;
Info<< "(septernion(vector(0, -1, 0))*q*septernion(vector(0, 1, 0))).transform(v) " Info<< "(septernion(vector(0, -1, 0))*q*septernion(vector(0, 1, 0)))"
<< (septernion(vector(0, -1, 0))*q*septernion(vector(0, 1, 0))).transform(v) << ".transform(v) "
<< (septernion(vector(0, -1, 0))
*q
*septernion(vector(0, 1, 0))).transform(v)
<< endl; << endl;
return 0; return 0;

View File

@ -347,7 +347,8 @@ void ReadProblem
char* name = new char[size + 1]; char* name = new char[size + 1];
CCMIOReadOptstr(NULL, boundary, "BoundaryName", &size, name); CCMIOReadOptstr(NULL, boundary, "BoundaryName", &size, name);
name[size] = '\0'; name[size] = '\0';
foamPatchNames[foamPatchI] = string::validate<word>(string(name)); foamPatchNames[foamPatchI] =
string::validate<word>(string(name));
delete [] name; delete [] name;
} }
else if else if
@ -359,7 +360,8 @@ void ReadProblem
char* name = new char[size + 1]; char* name = new char[size + 1];
CCMIOReadOptstr(NULL, boundary, "Label", &size, name); CCMIOReadOptstr(NULL, boundary, "Label", &size, name);
name[size] = '\0'; name[size] = '\0';
foamPatchNames[foamPatchI] = string::validate<word>(string(name)); foamPatchNames[foamPatchI] =
string::validate<word>(string(name));
delete [] name; delete [] name;
} }
else else
@ -641,7 +643,13 @@ int main(int argc, char *argv[])
// in NULL (which always means kCCMIONoErr) and then assign the return // in NULL (which always means kCCMIONoErr) and then assign the return
// value to 'err'.). // value to 'err'.).
CCMIOID root; CCMIOID root;
CCMIOError err = CCMIOOpenFile(NULL, ccmFile.c_str(), kCCMIORead, &root); CCMIOError err = CCMIOOpenFile
(
NULL,
ccmFile.c_str(),
kCCMIORead,
&root
);
// We are going to assume that we have a state with a known name. // We are going to assume that we have a state with a known name.
// We could instead use CCMIONextEntity() to walk through all the // We could instead use CCMIONextEntity() to walk through all the

View File

@ -236,7 +236,9 @@ void storeCellInZone
// Reads mesh format // Reads mesh format
scalar readMeshFormat(IFstream& inFile) scalar readMeshFormat(IFstream& inFile)
{ {
Info<< "Starting to read mesh format at line " << inFile.lineNumber() << endl; Info<< "Starting to read mesh format at line "
<< inFile.lineNumber()
<< endl;
string line; string line;
inFile.getLine(line); inFile.getLine(line);
@ -1086,4 +1088,3 @@ int main(int argc, char *argv[])
// ************************************************************************* // // ************************************************************************* //

View File

@ -33,7 +33,8 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
nonuniformTransformCyclicFvPatchField<Type>::nonuniformTransformCyclicFvPatchField nonuniformTransformCyclicFvPatchField<Type>::
nonuniformTransformCyclicFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
@ -44,7 +45,8 @@ nonuniformTransformCyclicFvPatchField<Type>::nonuniformTransformCyclicFvPatchFie
template<class Type> template<class Type>
nonuniformTransformCyclicFvPatchField<Type>::nonuniformTransformCyclicFvPatchField nonuniformTransformCyclicFvPatchField<Type>::
nonuniformTransformCyclicFvPatchField
( (
const nonuniformTransformCyclicFvPatchField<Type>& ptf, const nonuniformTransformCyclicFvPatchField<Type>& ptf,
const fvPatch& p, const fvPatch& p,
@ -57,7 +59,8 @@ nonuniformTransformCyclicFvPatchField<Type>::nonuniformTransformCyclicFvPatchFie
template<class Type> template<class Type>
nonuniformTransformCyclicFvPatchField<Type>::nonuniformTransformCyclicFvPatchField nonuniformTransformCyclicFvPatchField<Type>::
nonuniformTransformCyclicFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
@ -69,7 +72,8 @@ nonuniformTransformCyclicFvPatchField<Type>::nonuniformTransformCyclicFvPatchFie
template<class Type> template<class Type>
nonuniformTransformCyclicFvPatchField<Type>::nonuniformTransformCyclicFvPatchField nonuniformTransformCyclicFvPatchField<Type>::
nonuniformTransformCyclicFvPatchField
( (
const nonuniformTransformCyclicFvPatchField<Type>& ptf const nonuniformTransformCyclicFvPatchField<Type>& ptf
) )
@ -79,7 +83,8 @@ nonuniformTransformCyclicFvPatchField<Type>::nonuniformTransformCyclicFvPatchFie
template<class Type> template<class Type>
nonuniformTransformCyclicFvPatchField<Type>::nonuniformTransformCyclicFvPatchField nonuniformTransformCyclicFvPatchField<Type>::
nonuniformTransformCyclicFvPatchField
( (
const nonuniformTransformCyclicFvPatchField<Type>& ptf, const nonuniformTransformCyclicFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF

View File

@ -44,7 +44,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class nonuniformTransformCyclicFvPatch Declaration Class nonuniformTransformCyclicFvPatch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Type> template<class Type>
@ -77,7 +77,8 @@ public:
const dictionary& const dictionary&
); );
//- Construct by mapping given nonuniformTransformCyclicFvPatchField onto a new patch //- Construct by mapping given
// nonuniformTransformCyclicFvPatchField onto a new patch
nonuniformTransformCyclicFvPatchField nonuniformTransformCyclicFvPatchField
( (
const nonuniformTransformCyclicFvPatchField<Type>&, const nonuniformTransformCyclicFvPatchField<Type>&,

View File

@ -34,7 +34,12 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(nonuniformTransformCyclicFvPatch, 0); defineTypeNameAndDebug(nonuniformTransformCyclicFvPatch, 0);
addToRunTimeSelectionTable(fvPatch, nonuniformTransformCyclicFvPatch, polyPatch); addToRunTimeSelectionTable
(
fvPatch,
nonuniformTransformCyclicFvPatch,
polyPatch
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -44,7 +44,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class nonuniformTransformCyclicFvPatch Declaration Class nonuniformTransformCyclicFvPatch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class nonuniformTransformCyclicFvPatch class nonuniformTransformCyclicFvPatch
@ -61,7 +61,11 @@ public:
// Constructors // Constructors
//- Construct from polyPatch //- Construct from polyPatch
nonuniformTransformCyclicFvPatch(const polyPatch& patch, const fvBoundaryMesh& bm) nonuniformTransformCyclicFvPatch
(
const polyPatch& patch,
const fvBoundaryMesh& bm
)
: :
cyclicFvPatch(patch, bm) cyclicFvPatch(patch, bm)
{} {}

View File

@ -33,7 +33,8 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
nonuniformTransformCyclicFvsPatchField<Type>::nonuniformTransformCyclicFvsPatchField nonuniformTransformCyclicFvsPatchField<Type>::
nonuniformTransformCyclicFvsPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF const DimensionedField<Type, surfaceMesh>& iF
@ -44,7 +45,8 @@ nonuniformTransformCyclicFvsPatchField<Type>::nonuniformTransformCyclicFvsPatchF
template<class Type> template<class Type>
nonuniformTransformCyclicFvsPatchField<Type>::nonuniformTransformCyclicFvsPatchField nonuniformTransformCyclicFvsPatchField<Type>::
nonuniformTransformCyclicFvsPatchField
( (
const nonuniformTransformCyclicFvsPatchField<Type>& ptf, const nonuniformTransformCyclicFvsPatchField<Type>& ptf,
const fvPatch& p, const fvPatch& p,
@ -57,7 +59,8 @@ nonuniformTransformCyclicFvsPatchField<Type>::nonuniformTransformCyclicFvsPatchF
template<class Type> template<class Type>
nonuniformTransformCyclicFvsPatchField<Type>::nonuniformTransformCyclicFvsPatchField nonuniformTransformCyclicFvsPatchField<Type>::
nonuniformTransformCyclicFvsPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF, const DimensionedField<Type, surfaceMesh>& iF,
@ -69,7 +72,8 @@ nonuniformTransformCyclicFvsPatchField<Type>::nonuniformTransformCyclicFvsPatchF
template<class Type> template<class Type>
nonuniformTransformCyclicFvsPatchField<Type>::nonuniformTransformCyclicFvsPatchField nonuniformTransformCyclicFvsPatchField<Type>::
nonuniformTransformCyclicFvsPatchField
( (
const nonuniformTransformCyclicFvsPatchField<Type>& ptf const nonuniformTransformCyclicFvsPatchField<Type>& ptf
) )
@ -79,7 +83,8 @@ nonuniformTransformCyclicFvsPatchField<Type>::nonuniformTransformCyclicFvsPatchF
template<class Type> template<class Type>
nonuniformTransformCyclicFvsPatchField<Type>::nonuniformTransformCyclicFvsPatchField nonuniformTransformCyclicFvsPatchField<Type>::
nonuniformTransformCyclicFvsPatchField
( (
const nonuniformTransformCyclicFvsPatchField<Type>& ptf, const nonuniformTransformCyclicFvsPatchField<Type>& ptf,
const DimensionedField<Type, surfaceMesh>& iF const DimensionedField<Type, surfaceMesh>& iF

View File

@ -44,7 +44,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class nonuniformTransformCyclicFvsPatch Declaration Class nonuniformTransformCyclicFvsPatch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Type> template<class Type>
@ -76,7 +76,8 @@ public:
const dictionary& const dictionary&
); );
//- Construct by mapping given nonuniformTransformCyclicFvsPatchField onto a new patch //- Construct by mapping given
// nonuniformTransformCyclicFvsPatchField onto a new patch
nonuniformTransformCyclicFvsPatchField nonuniformTransformCyclicFvsPatchField
( (
const nonuniformTransformCyclicFvsPatchField<Type>&, const nonuniformTransformCyclicFvsPatchField<Type>&,

View File

@ -35,7 +35,8 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
nonuniformTransformCyclicPointPatchField<Type>::nonuniformTransformCyclicPointPatchField nonuniformTransformCyclicPointPatchField<Type>::
nonuniformTransformCyclicPointPatchField
( (
const pointPatch& p, const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF const DimensionedField<Type, pointMesh>& iF
@ -46,7 +47,8 @@ nonuniformTransformCyclicPointPatchField<Type>::nonuniformTransformCyclicPointPa
template<class Type> template<class Type>
nonuniformTransformCyclicPointPatchField<Type>::nonuniformTransformCyclicPointPatchField nonuniformTransformCyclicPointPatchField<Type>::
nonuniformTransformCyclicPointPatchField
( (
const pointPatch& p, const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF, const DimensionedField<Type, pointMesh>& iF,
@ -58,7 +60,8 @@ nonuniformTransformCyclicPointPatchField<Type>::nonuniformTransformCyclicPointPa
template<class Type> template<class Type>
nonuniformTransformCyclicPointPatchField<Type>::nonuniformTransformCyclicPointPatchField nonuniformTransformCyclicPointPatchField<Type>::
nonuniformTransformCyclicPointPatchField
( (
const nonuniformTransformCyclicPointPatchField<Type>& ptf, const nonuniformTransformCyclicPointPatchField<Type>& ptf,
const pointPatch& p, const pointPatch& p,
@ -71,7 +74,8 @@ nonuniformTransformCyclicPointPatchField<Type>::nonuniformTransformCyclicPointPa
template<class Type> template<class Type>
nonuniformTransformCyclicPointPatchField<Type>::nonuniformTransformCyclicPointPatchField nonuniformTransformCyclicPointPatchField<Type>::
nonuniformTransformCyclicPointPatchField
( (
const nonuniformTransformCyclicPointPatchField<Type>& ptf, const nonuniformTransformCyclicPointPatchField<Type>& ptf,
const DimensionedField<Type, pointMesh>& iF const DimensionedField<Type, pointMesh>& iF
@ -84,7 +88,10 @@ nonuniformTransformCyclicPointPatchField<Type>::nonuniformTransformCyclicPointPa
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
void nonuniformTransformCyclicPointPatchField<Type>::evaluate(const Pstream::commsTypes) void nonuniformTransformCyclicPointPatchField<Type>::evaluate
(
const Pstream::commsTypes
)
{ {
const vectorField& nHat = this->patch().pointNormals(); const vectorField& nHat = this->patch().pointNormals();

View File

@ -32,8 +32,18 @@ namespace Foam
{ {
defineTypeNameAndDebug(nonuniformTransformCyclicPolyPatch, 0); defineTypeNameAndDebug(nonuniformTransformCyclicPolyPatch, 0);
addToRunTimeSelectionTable(polyPatch, nonuniformTransformCyclicPolyPatch, word); addToRunTimeSelectionTable
addToRunTimeSelectionTable(polyPatch, nonuniformTransformCyclicPolyPatch, dictionary); (
polyPatch,
nonuniformTransformCyclicPolyPatch,
word
);
addToRunTimeSelectionTable
(
polyPatch,
nonuniformTransformCyclicPolyPatch,
dictionary
);
} }

View File

@ -1245,15 +1245,19 @@ label findCorrespondingRegion
// { // {
// forAll(cellRegion, cellI) // forAll(cellRegion, cellI)
// { // {
// if (cellRegion[cellI] == regionI && existingZoneID[cellI] != zoneI) // if
// (
// cellRegion[cellI] == regionI
// && existingZoneID[cellI] != zoneI
// )
// { // {
// // cellI in regionI but not in zoneI // // cellI in regionI but not in zoneI
// regionI = -1; // regionI = -1;
// break; // break;
// } // }
// } // }
// // If one in error, all should be in error. Note that branch gets taken // // If one in error, all should be in error. Note that branch
// // on all procs. // // gets taken on all procs.
// reduce(regionI, minOp<label>()); // reduce(regionI, minOp<label>());
// } // }
// //

View File

@ -452,7 +452,8 @@ int main(int argc, char *argv[])
<< "(there is a points file in " << pointsInstance << "(there is a points file in " << pointsInstance
<< ")" << endl << ")" << endl
<< "Please rerun with the correct time specified" << "Please rerun with the correct time specified"
<< " (through the -constant, -time or -latestTime (at your option)." << " (through the -constant, -time or -latestTime "
<< "(at your option)."
<< endl << exit(FatalError); << endl << exit(FatalError);
} }

View File

@ -1272,7 +1272,10 @@ int main(int argc, char *argv[])
//Info<< " symm tensors :"; //Info<< " symm tensors :";
//print(Info, symmNames); //print(Info, symmNames);
// //
//wordList tensorNames(sprayObjs.names(tensorIOField::typeName)); //wordList tensorNames
//(
// sprayObjs.names(tensorIOField::typeName)
//);
//Info<< " tensors :"; //Info<< " tensors :";
//print(Info, tensorNames); //print(Info, tensorNames);

View File

@ -112,7 +112,10 @@ Note
@verbatim @verbatim
<?xml version="1.0"?> <?xml version="1.0"?>
<VTKFile type="Collection" version="0.1" byte_order="LittleEndian" compressor="vtkZLibDataCompressor"> <VTKFile type="Collection"
version="0.1"
byte_order="LittleEndian"
compressor="vtkZLibDataCompressor">
<Collection> <Collection>
<DataSet timestep="50" file="pitzDaily_2.vtu"/> <DataSet timestep="50" file="pitzDaily_2.vtu"/>
<DataSet timestep="100" file="pitzDaily_3.vtu"/> <DataSet timestep="100" file="pitzDaily_3.vtu"/>

View File

@ -19,7 +19,8 @@ int USERD_get_maxsize_info
label nPyr05Max = 0; label nPyr05Max = 0;
label nTet04Max = 0; label nTet04Max = 0;
Info<< "Checking all time steps for EnSight memory allocation purpose. This can take some time." << endl; Info<< "Checking all time steps for EnSight memory allocation purpose. "
<< "This can take some time." << endl;
for (label timeI=1; timeI < timeDirs.size(); ++timeI) for (label timeI=1; timeI < timeDirs.size(); ++timeI)
{ {

View File

@ -1,4 +1,3 @@
int USERD_get_nsided_conn int USERD_get_nsided_conn
( (
int part_number, int part_number,
@ -13,7 +12,8 @@ int USERD_get_nsided_conn
#endif #endif
if (part_number == 1) if (part_number == 1)
{ {
Info<< "************* EEEEEEEEERRRRRRRRRRRRRRRRRR *************** " << endl << flush; Info<< "************* EEEEEEEEERRRRRRRRRRRRRRRRRR *************** "
<< endl << flush;
} }
else if (part_number < nPatches+2) else if (part_number < nPatches+2)

View File

@ -198,7 +198,8 @@ int USERD_set_filenames
runTime.setTime(timeDirs[Current_time_step], Current_time_step); runTime.setTime(timeDirs[Current_time_step], Current_time_step);
Num_variables = nVar + nSprayVariables; Num_variables = nVar + nSprayVariables;
Numparts_available = Num_unstructured_parts + Num_structured_parts + nPatches; Numparts_available =
Num_unstructured_parts + Num_structured_parts + nPatches;
#ifdef ENSIGHTDEBUG #ifdef ENSIGHTDEBUG
Info<< "Leaving: USERD_set_filenames" << endl << flush; Info<< "Leaving: USERD_set_filenames" << endl << flush;
@ -206,4 +207,3 @@ int USERD_set_filenames
return Z_OK; return Z_OK;
} }

View File

@ -59,7 +59,12 @@ volVectorField U
vector zT = swirlAxis; vector zT = swirlAxis;
vector yT = vector(0, zT.z(), -zT.y()); vector yT = vector(0, zT.z(), -zT.y());
vector xT = vector(zT.y()*zT.y() + zT.z()*zT.z(), -zT.x()*zT.y(), -zT.x()*zT.z()); vector xT = vector
(
zT.y()*zT.y() + zT.z()*zT.z(),
-zT.x()*zT.y(),
-zT.x()*zT.z()
);
// if swirl is around (1, 0, 0) we have to find another transformation // if swirl is around (1, 0, 0) we have to find another transformation
if (mag(yT) < SMALL) if (mag(yT) < SMALL)

View File

@ -73,145 +73,145 @@ Quaternion model_orientation; // orientation of bunny
// it had gotten down to 5 vertices. // it had gotten down to 5 vertices.
// No need to draw a one dimensional polygon. :-) // No need to draw a one dimensional polygon. :-)
int Map(int a,int mx) { int Map(int a,int mx) {
if(mx<=0) return 0; if(mx<=0) return 0;
while(a>=mx) { while(a>=mx) {
a=collapse_map[a]; a=collapse_map[a];
} }
return a; return a;
} }
void DrawModelTriangles() { void DrawModelTriangles() {
assert(collapse_map.num); assert(collapse_map.num);
renderpolycount=0; renderpolycount=0;
int i=0; int i=0;
for(i=0;i<tri.num;i++) { for(i=0;i<tri.num;i++) {
int p0= Map(tri[i].v[0],render_num); int p0= Map(tri[i].v[0],render_num);
int p1= Map(tri[i].v[1],render_num); int p1= Map(tri[i].v[1],render_num);
int p2= Map(tri[i].v[2],render_num); int p2= Map(tri[i].v[2],render_num);
// note: serious optimization opportunity here, // note: serious optimization opportunity here,
// by sorting the triangles the following "continue" // by sorting the triangles the following "continue"
// could have been made into a "break" statement. // could have been made into a "break" statement.
if(p0==p1 || p1==p2 || p2==p0) continue; if(p0==p1 || p1==p2 || p2==p0) continue;
renderpolycount++; renderpolycount++;
// if we are not currenly morphing between 2 levels of detail // if we are not currenly morphing between 2 levels of detail
// (i.e. if morph=1.0) then q0,q1, and q2 are not necessary. // (i.e. if morph=1.0) then q0,q1, and q2 are not necessary.
int q0= Map(p0,(int)(render_num*lodbase)); int q0= Map(p0,(int)(render_num*lodbase));
int q1= Map(p1,(int)(render_num*lodbase)); int q1= Map(p1,(int)(render_num*lodbase));
int q2= Map(p2,(int)(render_num*lodbase)); int q2= Map(p2,(int)(render_num*lodbase));
Vector v0,v1,v2; Vector v0,v1,v2;
v0 = vert[p0]*morph + vert[q0]*(1-morph); v0 = vert[p0]*morph + vert[q0]*(1-morph);
v1 = vert[p1]*morph + vert[q1]*(1-morph); v1 = vert[p1]*morph + vert[q1]*(1-morph);
v2 = vert[p2]*morph + vert[q2]*(1-morph); v2 = vert[p2]*morph + vert[q2]*(1-morph);
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
// the purpose of the demo is to show polygons // the purpose of the demo is to show polygons
// therefore just use 1 face normal (flat shading) // therefore just use 1 face normal (flat shading)
Vector nrml = (v1-v0) * (v2-v1); // cross product Vector nrml = (v1-v0) * (v2-v1); // cross product
if(0<magnitude(nrml)) { if(0<magnitude(nrml)) {
glNormal3fv(normalize(nrml)); glNormal3fv(normalize(nrml));
} }
glVertex3fv(v0); glVertex3fv(v0);
glVertex3fv(v1); glVertex3fv(v1);
glVertex3fv(v2); glVertex3fv(v2);
glEnd(); glEnd();
} }
} }
void PermuteVertices(List<int> &permutation) { void PermuteVertices(List<int> &permutation) {
// rearrange the vertex list // rearrange the vertex list
List<Vector> temp_list; List<Vector> temp_list;
int i; int i;
assert(permutation.num==vert.num); assert(permutation.num==vert.num);
for(i=0;i<vert.num;i++) { for(i=0;i<vert.num;i++) {
temp_list.Add(vert[i]); temp_list.Add(vert[i]);
} }
for(i=0;i<vert.num;i++) { for(i=0;i<vert.num;i++) {
vert[permutation[i]]=temp_list[i]; vert[permutation[i]]=temp_list[i];
} }
// update the changes in the entries in the triangle list // update the changes in the entries in the triangle list
for(i=0;i<tri.num;i++) { for(i=0;i<tri.num;i++) {
for(int j=0;j<3;j++) { for(int j=0;j<3;j++) {
tri[i].v[j] = permutation[tri[i].v[j]]; tri[i].v[j] = permutation[tri[i].v[j]];
} }
} }
} }
void GetRabbitData(){ void GetRabbitData(){
// Copy the geometry from the arrays of data in rabdata.cpp into // Copy the geometry from the arrays of data in rabdata.cpp into
// the vert and tri lists which we send to the reduction routine // the vert and tri lists which we send to the reduction routine
int i; int i;
for(i=0;i<RABBIT_VERTEX_NUM;i++) { for(i=0;i<RABBIT_VERTEX_NUM;i++) {
float *vp=rabbit_vertices[i]; float *vp=rabbit_vertices[i];
vert.Add(Vector(vp[0],vp[1],vp[2])); vert.Add(Vector(vp[0],vp[1],vp[2]));
} }
for(i=0;i<RABBIT_TRIANGLE_NUM;i++) { for(i=0;i<RABBIT_TRIANGLE_NUM;i++) {
tridata td; tridata td;
td.v[0]=rabbit_triangles[i][0]; td.v[0]=rabbit_triangles[i][0];
td.v[1]=rabbit_triangles[i][1]; td.v[1]=rabbit_triangles[i][1];
td.v[2]=rabbit_triangles[i][2]; td.v[2]=rabbit_triangles[i][2];
tri.Add(td); tri.Add(td);
} }
render_num=vert.num; // by default lets use all the model to render render_num=vert.num; // by default lets use all the model to render
} }
void InitModel() { void InitModel() {
List<int> permutation; List<int> permutation;
GetRabbitData(); GetRabbitData();
ProgressiveMesh(vert,tri,collapse_map,permutation); ProgressiveMesh(vert,tri,collapse_map,permutation);
PermuteVertices(permutation); PermuteVertices(permutation);
model_position = Vector(0,0,-3); model_position = Vector(0,0,-3);
Quaternion yaw(Vector(0,1,0),-3.14f/4); // 45 degrees Quaternion yaw(Vector(0,1,0),-3.14f/4); // 45 degrees
Quaternion pitch(Vector(1,0,0),3.14f/12); // 15 degrees Quaternion pitch(Vector(1,0,0),3.14f/12); // 15 degrees
model_orientation = pitch*yaw; model_orientation = pitch*yaw;
} }
void StatusDraw() { void StatusDraw() {
// Draw a slider type widget looking thing // Draw a slider type widget looking thing
// to show portion of vertices being used // to show portion of vertices being used
float b = (float)render_num/(float)vert.num; float b = (float)render_num/(float)vert.num;
float a = b*(lodbase ); float a = b*(lodbase );
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glMatrixMode( GL_PROJECTION ); glMatrixMode( GL_PROJECTION );
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glOrtho(-0.15,15,-0.1,1.1,-0.1,100); glOrtho(-0.15,15,-0.1,1.1,-0.1,100);
glMatrixMode( GL_MODELVIEW ); glMatrixMode( GL_MODELVIEW );
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
glColor3f(1,0,0); glColor3f(1,0,0);
glVertex2f(0,0); glVertex2f(0,0);
glVertex2f(1,0); glVertex2f(1,0);
glVertex2f(1,a); glVertex2f(1,a);
glVertex2f(0,a); glVertex2f(0,a);
glEnd(); glEnd();
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
glColor3f(1,0,0); glColor3f(1,0,0);
glVertex2f(0,a); glVertex2f(0,a);
glVertex2f(morph,a); glVertex2f(morph,a);
glVertex2f(morph,b); glVertex2f(morph,b);
glVertex2f(0,b); glVertex2f(0,b);
glEnd(); glEnd();
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
glColor3f(0,0,1); glColor3f(0,0,1);
glVertex2f(morph,a); glVertex2f(morph,a);
glVertex2f(1,a); glVertex2f(1,a);
glVertex2f(1,b); glVertex2f(1,b);
glVertex2f(morph,b); glVertex2f(morph,b);
glEnd(); glEnd();
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
glColor3f(0,0,1); glColor3f(0,0,1);
glVertex2f(0,b); glVertex2f(0,b);
glVertex2f(1,b); glVertex2f(1,b);
glVertex2f(1,1); glVertex2f(1,1);
glVertex2f(0,1); glVertex2f(0,1);
glEnd(); glEnd();
glPopMatrix(); glPopMatrix();
glMatrixMode( GL_PROJECTION ); glMatrixMode( GL_PROJECTION );
glPopMatrix(); glPopMatrix();
glMatrixMode( GL_MODELVIEW ); glMatrixMode( GL_MODELVIEW );
} }
/* /*
@ -219,65 +219,64 @@ void StatusDraw() {
* the object through various polygon reduced versions. * the object through various polygon reduced versions.
*/ */
struct keyframethings { struct keyframethings {
float t; // timestamp float t; // timestamp
float n; // portion of vertices used to start float n; // portion of vertices used to start
float dn; // rate of change in "n" float dn; // rate of change in "n"
float m; // morph value float m; // morph value
float dm; // rate of change in "m" float dm; // rate of change in "m"
} keys[]={ } keys[]={
{0 ,1 ,0 ,1, 0}, {0 ,1 ,0 ,1, 0},
{2 ,1 ,-1,1, 0}, {2 ,1 ,-1,1, 0},
{10,0 ,1 ,1, 0}, {10,0 ,1 ,1, 0},
{18,1 ,0 ,1, 0}, {18,1 ,0 ,1, 0},
{20,1 ,0 ,1,-1}, {20,1 ,0 ,1,-1},
{24,0.5 ,0 ,1, 0}, {24,0.5 ,0 ,1, 0},
{26,0.5 ,0 ,1,-1}, {26,0.5 ,0 ,1,-1},
{30,0.25,0 ,1, 0}, {30,0.25,0 ,1, 0},
{32,0.25,0 ,1,-1}, {32,0.25,0 ,1,-1},
{36,0.125,0,1, 0}, {36,0.125,0,1, 0},
{38,0.25,0 ,0, 1}, {38,0.25,0 ,0, 1},
{42,0.5 ,0 ,0, 1}, {42,0.5 ,0 ,0, 1},
{46,1 ,0 ,0, 1}, {46,1 ,0 ,0, 1},
{50,1 ,0 ,1, 0}, {50,1 ,0 ,1, 0},
}; };
void AnimateParameters() { void AnimateParameters() {
static float time=0; // global time - used for animation static float time=0; // global time - used for animation
time+=DeltaT; time+=DeltaT;
if(time>=50) time=0; // repeat cycle every so many seconds if(time>=50) time=0; // repeat cycle every so many seconds
int k=0; int k=0;
while(time>keys[k+1].t) { while(time>keys[k+1].t) {
k++; k++;
} }
float interp = (time-keys[k].t)/(keys[k+1].t-keys[k].t); float interp = (time-keys[k].t)/(keys[k+1].t-keys[k].t);
render_num = vert.num*(keys[k].n + interp*keys[k].dn); render_num = vert.num*(keys[k].n + interp*keys[k].dn);
morph = keys[k].m + interp*keys[k].dm; morph = keys[k].m + interp*keys[k].dm;
morph = (morph>1.0f) ? 1.0f : morph; // clamp value morph = (morph>1.0f) ? 1.0f : morph; // clamp value
if(render_num>vert.num) render_num=vert.num; if(render_num>vert.num) render_num=vert.num;
if(render_num<0 ) render_num=0; if(render_num<0 ) render_num=0;
} }
void RenderModel() { void RenderModel() {
AnimateParameters(); AnimateParameters();
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0); glEnable(GL_LIGHT0);
glColor3f(1,1,1); glColor3f(1,1,1);
glPushMatrix(); glPushMatrix();
glTranslatef(model_position.x,model_position.y,model_position.z); glTranslatef(model_position.x,model_position.y,model_position.z);
// Rotate by quaternion: model_orientation // Rotate by quaternion: model_orientation
Vector axis=model_orientation.axis(); Vector axis=model_orientation.axis();
float angle=model_orientation.angle()*180.0f/3.14f; float angle=model_orientation.angle()*180.0f/3.14f;
glRotatef(angle,axis.x,axis.y,axis.z); glRotatef(angle,axis.x,axis.y,axis.z);
DrawModelTriangles(); DrawModelTriangles();
StatusDraw(); StatusDraw();
glPopMatrix(); glPopMatrix();
char buf[256]; char buf[256];
sprintf(buf,"Polys: %d Vertices: %d ",renderpolycount,render_num); sprintf(buf,"Polys: %d Vertices: %d ",renderpolycount,render_num);
if(morph<1.0) { if(morph<1.0) {
sprintf(buf+strlen(buf),"<-> %d morph: %4.2f ", sprintf(buf+strlen(buf),"<-> %d morph: %4.2f ",
(int)(lodbase *render_num),morph); (int)(lodbase *render_num),morph);
} }
PostString(buf,0,-2,5); PostString(buf,0,-2,5);
} }

View File

@ -6,4 +6,3 @@ void PostString(char *_s,int _x,int _y,float _life=5.0);
void RenderStrings(); void RenderStrings();
#endif #endif

View File

@ -10,115 +10,117 @@
#include <stdio.h> #include <stdio.h>
template <class Type> class List { template <class Type> class List {
public: public:
List(int s=0); List(int s=0);
~List(); ~List();
void allocate(int s); void allocate(int s);
void SetSize(int s); void SetSize(int s);
void Pack(); void Pack();
void Add(Type); void Add(Type);
void AddUnique(Type); void AddUnique(Type);
int Contains(Type); int Contains(Type);
void Remove(Type); void Remove(Type);
void DelIndex(int i); void DelIndex(int i);
Type * element; Type * element;
int num; int num;
int array_size; int array_size;
Type &operator[](int i){assert(i>=0 && i<num); return element[i];} Type &operator[](int i){
assert(i>=0 && i<num);
return element[i];}
}; };
template <class Type> template <class Type>
List<Type>::List(int s){ List<Type>::List(int s){
num=0; num=0;
array_size = 0; array_size = 0;
element = NULL; element = NULL;
if(s) { if(s) {
allocate(s); allocate(s);
} }
} }
template <class Type> template <class Type>
List<Type>::~List(){ List<Type>::~List(){
delete element; delete element;
} }
template <class Type> template <class Type>
void List<Type>::allocate(int s){ void List<Type>::allocate(int s){
assert(s>0); assert(s>0);
assert(s>=num); assert(s>=num);
Type *old = element; Type *old = element;
array_size =s; array_size =s;
element = new Type[array_size]; element = new Type[array_size];
assert(element); assert(element);
for(int i=0;i<num;i++){ for(int i=0;i<num;i++){
element[i]=old[i]; element[i]=old[i];
} }
if(old) delete old; if(old) delete old;
} }
template <class Type> template <class Type>
void List<Type>::SetSize(int s){ void List<Type>::SetSize(int s){
if(s==0) { if(element) delete element;} if(s==0) { if(element) delete element;}
else { allocate(s); } else { allocate(s); }
num=s; num=s;
} }
template <class Type> template <class Type>
void List<Type>::Pack(){ void List<Type>::Pack(){
allocate(num); allocate(num);
} }
template <class Type> template <class Type>
void List<Type>::Add(Type t){ void List<Type>::Add(Type t){
assert(num<=array_size); assert(num<=array_size);
if(num==array_size) { if(num==array_size) {
allocate((array_size)?array_size *2:16); allocate((array_size)?array_size *2:16);
} }
//int i; //int i;
//for(i=0;i<num;i++) { //for(i=0;i<num;i++) {
// dissallow duplicates // dissallow duplicates
// assert(element[i] != t); // assert(element[i] != t);
//} //}
element[num++] = t; element[num++] = t;
} }
template <class Type> template <class Type>
int List<Type>::Contains(Type t){ int List<Type>::Contains(Type t){
int i; int i;
int count=0; int count=0;
for(i=0;i<num;i++) { for(i=0;i<num;i++) {
if(element[i] == t) count++; if(element[i] == t) count++;
} }
return count; return count;
} }
template <class Type> template <class Type>
void List<Type>::AddUnique(Type t){ void List<Type>::AddUnique(Type t){
if(!Contains(t)) Add(t); if(!Contains(t)) Add(t);
} }
template <class Type> template <class Type>
void List<Type>::DelIndex(int i){ void List<Type>::DelIndex(int i){
assert(i<num); assert(i<num);
num--; num--;
while(i<num){ while(i<num){
element[i] = element[i+1]; element[i] = element[i+1];
i++; i++;
} }
} }
template <class Type> template <class Type>
void List<Type>::Remove(Type t){ void List<Type>::Remove(Type t){
int i; int i;
for(i=0;i<num;i++) { for(i=0;i<num;i++) {
if(element[i] == t) { if(element[i] == t) {
break; break;
} }
} }
DelIndex(i); DelIndex(i);
for(i=0;i<num;i++) { for(i=0;i<num;i++) {
assert(element[i] != t); assert(element[i] != t);
} }
} }

View File

@ -33,281 +33,283 @@ class Vertex;
class Triangle { class Triangle {
public: public:
Vertex * vertex[3]; // the 3 points that make this tri Vertex * vertex[3]; // the 3 points that make this tri
Vector normal; // unit vector othogonal to this face Vector normal; // unit vector othogonal to this face
Triangle(Vertex *v0,Vertex *v1,Vertex *v2); Triangle(Vertex *v0,Vertex *v1,Vertex *v2);
~Triangle(); ~Triangle();
void ComputeNormal(); void ComputeNormal();
void ReplaceVertex(Vertex *vold,Vertex *vnew); void ReplaceVertex(Vertex *vold,Vertex *vnew);
int HasVertex(Vertex *v); int HasVertex(Vertex *v);
}; };
class Vertex { class Vertex {
public: public:
Vector position; // location of point in euclidean space Vector position; // location of point in euclidean space
int id; // place of vertex in original list int id; // place of vertex in original list
List<Vertex *> neighbor; // adjacent vertices List<Vertex *> neighbor; // adjacent vertices
List<Triangle *> face; // adjacent triangles List<Triangle *> face; // adjacent triangles
float objdist; // cached cost of collapsing edge float objdist; // cached cost of collapsing edge
Vertex * collapse; // candidate vertex for collapse Vertex * collapse; // candidate vertex for collapse
Vertex(Vector v,int _id); Vertex(Vector v,int _id);
~Vertex(); ~Vertex();
void RemoveIfNonNeighbor(Vertex *n); void RemoveIfNonNeighbor(Vertex *n);
}; };
List<Vertex *> vertices; List<Vertex *> vertices;
List<Triangle *> triangles; List<Triangle *> triangles;
Triangle::Triangle(Vertex *v0,Vertex *v1,Vertex *v2){ Triangle::Triangle(Vertex *v0,Vertex *v1,Vertex *v2){
assert(v0!=v1 && v1!=v2 && v2!=v0); assert(v0!=v1 && v1!=v2 && v2!=v0);
vertex[0]=v0; vertex[0]=v0;
vertex[1]=v1; vertex[1]=v1;
vertex[2]=v2; vertex[2]=v2;
ComputeNormal(); ComputeNormal();
triangles.Add(this); triangles.Add(this);
for(int i=0;i<3;i++) { for(int i=0;i<3;i++) {
vertex[i]->face.Add(this); vertex[i]->face.Add(this);
for(int j=0;j<3;j++) if(i!=j) { for(int j=0;j<3;j++) if(i!=j) {
vertex[i]->neighbor.AddUnique(vertex[j]); vertex[i]->neighbor.AddUnique(vertex[j]);
} }
} }
} }
Triangle::~Triangle(){ Triangle::~Triangle(){
int i; int i;
triangles.Remove(this); triangles.Remove(this);
for(i=0;i<3;i++) { for(i=0;i<3;i++) {
if(vertex[i]) vertex[i]->face.Remove(this); if(vertex[i]) vertex[i]->face.Remove(this);
} }
for(i=0;i<3;i++) { for(i=0;i<3;i++) {
int i2 = (i+1)%3; int i2 = (i+1)%3;
if(!vertex[i] || !vertex[i2]) continue; if(!vertex[i] || !vertex[i2]) continue;
vertex[i ]->RemoveIfNonNeighbor(vertex[i2]); vertex[i ]->RemoveIfNonNeighbor(vertex[i2]);
vertex[i2]->RemoveIfNonNeighbor(vertex[i ]); vertex[i2]->RemoveIfNonNeighbor(vertex[i ]);
} }
} }
int Triangle::HasVertex(Vertex *v) { int Triangle::HasVertex(Vertex *v) {
return (v==vertex[0] ||v==vertex[1] || v==vertex[2]); return (v==vertex[0] ||v==vertex[1] || v==vertex[2]);
} }
void Triangle::ComputeNormal(){ void Triangle::ComputeNormal(){
Vector v0=vertex[0]->position; Vector v0=vertex[0]->position;
Vector v1=vertex[1]->position; Vector v1=vertex[1]->position;
Vector v2=vertex[2]->position; Vector v2=vertex[2]->position;
normal = (v1-v0)*(v2-v1); normal = (v1-v0)*(v2-v1);
if(magnitude(normal)==0)return; if(magnitude(normal)==0)return;
normal = normalize(normal); normal = normalize(normal);
} }
void Triangle::ReplaceVertex(Vertex *vold,Vertex *vnew) { void Triangle::ReplaceVertex(Vertex *vold,Vertex *vnew) {
assert(vold && vnew); assert(vold && vnew);
assert(vold==vertex[0] || vold==vertex[1] || vold==vertex[2]); assert(vold==vertex[0] || vold==vertex[1] || vold==vertex[2]);
assert(vnew!=vertex[0] && vnew!=vertex[1] && vnew!=vertex[2]); assert(vnew!=vertex[0] && vnew!=vertex[1] && vnew!=vertex[2]);
if(vold==vertex[0]){ if(vold==vertex[0]){
vertex[0]=vnew; vertex[0]=vnew;
} }
else if(vold==vertex[1]){ else if(vold==vertex[1]){
vertex[1]=vnew; vertex[1]=vnew;
} }
else { else {
assert(vold==vertex[2]); assert(vold==vertex[2]);
vertex[2]=vnew; vertex[2]=vnew;
} }
int i; int i;
vold->face.Remove(this); vold->face.Remove(this);
assert(!vnew->face.Contains(this)); assert(!vnew->face.Contains(this));
vnew->face.Add(this); vnew->face.Add(this);
for(i=0;i<3;i++) { for(i=0;i<3;i++) {
vold->RemoveIfNonNeighbor(vertex[i]); vold->RemoveIfNonNeighbor(vertex[i]);
vertex[i]->RemoveIfNonNeighbor(vold); vertex[i]->RemoveIfNonNeighbor(vold);
} }
for(i=0;i<3;i++) { for(i=0;i<3;i++) {
assert(vertex[i]->face.Contains(this)==1); assert(vertex[i]->face.Contains(this)==1);
for(int j=0;j<3;j++) if(i!=j) { for(int j=0;j<3;j++) if(i!=j) {
vertex[i]->neighbor.AddUnique(vertex[j]); vertex[i]->neighbor.AddUnique(vertex[j]);
} }
} }
ComputeNormal(); ComputeNormal();
} }
Vertex::Vertex(Vector v,int _id) { Vertex::Vertex(Vector v,int _id) {
position =v; position =v;
id=_id; id=_id;
vertices.Add(this); vertices.Add(this);
} }
Vertex::~Vertex(){ Vertex::~Vertex(){
assert(face.num==0); assert(face.num==0);
while(neighbor.num) { while(neighbor.num) {
neighbor[0]->neighbor.Remove(this); neighbor[0]->neighbor.Remove(this);
neighbor.Remove(neighbor[0]); neighbor.Remove(neighbor[0]);
} }
vertices.Remove(this); vertices.Remove(this);
} }
void Vertex::RemoveIfNonNeighbor(Vertex *n) { void Vertex::RemoveIfNonNeighbor(Vertex *n) {
// removes n from neighbor list if n isn't a neighbor. // removes n from neighbor list if n isn't a neighbor.
if(!neighbor.Contains(n)) return; if(!neighbor.Contains(n)) return;
for(int i=0;i<face.num;i++) { for(int i=0;i<face.num;i++) {
if(face[i]->HasVertex(n)) return; if(face[i]->HasVertex(n)) return;
} }
neighbor.Remove(n); neighbor.Remove(n);
} }
float ComputeEdgeCollapseCost(Vertex *u,Vertex *v) { float ComputeEdgeCollapseCost(Vertex *u,Vertex *v) {
// if we collapse edge uv by moving u to v then how // if we collapse edge uv by moving u to v then how
// much different will the model change, i.e. how much "error". // much different will the model change, i.e. how much "error".
// Texture, vertex normal, and border vertex code was removed // Texture, vertex normal, and border vertex code was removed
// to keep this demo as simple as possible. // to keep this demo as simple as possible.
// The method of determining cost was designed in order // The method of determining cost was designed in order
// to exploit small and coplanar regions for // to exploit small and coplanar regions for
// effective polygon reduction. // effective polygon reduction.
// Is is possible to add some checks here to see if "folds" // Is is possible to add some checks here to see if "folds"
// would be generated. i.e. normal of a remaining face gets // would be generated. i.e. normal of a remaining face gets
// flipped. I never seemed to run into this problem and // flipped. I never seemed to run into this problem and
// therefore never added code to detect this case. // therefore never added code to detect this case.
int i; int i;
float edgelength = magnitude(v->position - u->position); float edgelength = magnitude(v->position - u->position);
float curvature=0; float curvature=0;
// find the "sides" triangles that are on the edge uv // find the "sides" triangles that are on the edge uv
List<Triangle *> sides; List<Triangle *> sides;
for(i=0;i<u->face.num;i++) { for(i=0;i<u->face.num;i++) {
if(u->face[i]->HasVertex(v)){ if(u->face[i]->HasVertex(v)){
sides.Add(u->face[i]); sides.Add(u->face[i]);
} }
} }
// use the triangle facing most away from the sides // use the triangle facing most away from the sides
// to determine our curvature term // to determine our curvature term
for(i=0;i<u->face.num;i++) { for(i=0;i<u->face.num;i++) {
float mincurv=1; // curve for face i and closer side to it float mincurv=1; // curve for face i and closer side to it
for(int j=0;j<sides.num;j++) { for(int j=0;j<sides.num;j++) {
// use dot product of face normals. '^' defined in vector // use dot product of face normals. '^'
float dotprod = u->face[i]->normal ^ sides[j]->normal; // defined in vector
mincurv = min(mincurv,(1-dotprod)/2.0f); float dotprod = u->face[i]->normal ^ sides[j]->normal;
} mincurv = min(mincurv,(1-dotprod)/2.0f);
curvature = max(curvature,mincurv); }
} curvature = max(curvature,mincurv);
// the more coplanar the lower the curvature term }
return edgelength * curvature; // the more coplanar the lower the curvature term
return edgelength * curvature;
} }
void ComputeEdgeCostAtVertex(Vertex *v) { void ComputeEdgeCostAtVertex(Vertex *v) {
// compute the edge collapse cost for all edges that start // compute the edge collapse cost for all edges that start
// from vertex v. Since we are only interested in reducing // from vertex v. Since we are only interested in reducing
// the object by selecting the min cost edge at each step, we // the object by selecting the min cost edge at each step, we
// only cache the cost of the least cost edge at this vertex // only cache the cost of the least cost edge at this vertex
// (in member variable collapse) as well as the value of the // (in member variable collapse) as well as the value of the
// cost (in member variable objdist). // cost (in member variable objdist).
if(v->neighbor.num==0) { if(v->neighbor.num==0) {
// v doesn't have neighbors so it costs nothing to collapse // v doesn't have neighbors so it costs nothing to collapse
v->collapse=NULL; v->collapse=NULL;
v->objdist=-0.01f; v->objdist=-0.01f;
return; return;
} }
v->objdist = 1000000; v->objdist = 1000000;
v->collapse=NULL; v->collapse=NULL;
// search all neighboring edges for "least cost" edge // search all neighboring edges for "least cost" edge
for(int i=0;i<v->neighbor.num;i++) { for(int i=0;i<v->neighbor.num;i++) {
float dist; float dist;
dist = ComputeEdgeCollapseCost(v,v->neighbor[i]); dist = ComputeEdgeCollapseCost(v,v->neighbor[i]);
if(dist<v->objdist) { if(dist<v->objdist) {
v->collapse=v->neighbor[i]; // candidate for edge collapse // candidate for edge collapse
v->objdist=dist; // cost of the collapse v->collapse=v->neighbor[i];
} // cost of the collapse
} v->objdist=dist;
}
}
} }
void ComputeAllEdgeCollapseCosts() { void ComputeAllEdgeCollapseCosts() {
// For all the edges, compute the difference it would make // For all the edges, compute the difference it would make
// to the model if it was collapsed. The least of these // to the model if it was collapsed. The least of these
// per vertex is cached in each vertex object. // per vertex is cached in each vertex object.
for(int i=0;i<vertices.num;i++) { for(int i=0;i<vertices.num;i++) {
ComputeEdgeCostAtVertex(vertices[i]); ComputeEdgeCostAtVertex(vertices[i]);
} }
} }
void Collapse(Vertex *u,Vertex *v){ void Collapse(Vertex *u,Vertex *v){
// Collapse the edge uv by moving vertex u onto v // Collapse the edge uv by moving vertex u onto v
// Actually remove tris on uv, then update tris that // Actually remove tris on uv, then update tris that
// have u to have v, and then remove u. // have u to have v, and then remove u.
if(!v) { if(!v) {
// u is a vertex all by itself so just delete it // u is a vertex all by itself so just delete it
delete u; delete u;
return; return;
} }
int i; int i;
List<Vertex *>tmp; List<Vertex *>tmp;
// make tmp a list of all the neighbors of u // make tmp a list of all the neighbors of u
for(i=0;i<u->neighbor.num;i++) { for(i=0;i<u->neighbor.num;i++) {
tmp.Add(u->neighbor[i]); tmp.Add(u->neighbor[i]);
} }
// delete triangles on edge uv: // delete triangles on edge uv:
for(i=u->face.num-1;i>=0;i--) { for(i=u->face.num-1;i>=0;i--) {
if(u->face[i]->HasVertex(v)) { if(u->face[i]->HasVertex(v)) {
delete(u->face[i]); delete(u->face[i]);
} }
} }
// update remaining triangles to have v instead of u // update remaining triangles to have v instead of u
for(i=u->face.num-1;i>=0;i--) { for(i=u->face.num-1;i>=0;i--) {
u->face[i]->ReplaceVertex(u,v); u->face[i]->ReplaceVertex(u,v);
} }
delete u; delete u;
// recompute the edge collapse costs for neighboring vertices // recompute the edge collapse costs for neighboring vertices
for(i=0;i<tmp.num;i++) { for(i=0;i<tmp.num;i++) {
ComputeEdgeCostAtVertex(tmp[i]); ComputeEdgeCostAtVertex(tmp[i]);
} }
} }
void AddVertex(List<Vector> &vert){ void AddVertex(List<Vector> &vert){
for(int i=0;i<vert.num;i++) { for(int i=0;i<vert.num;i++) {
new Vertex(vert[i],i); new Vertex(vert[i],i);
} }
} }
void AddFaces(List<tridata> &tri){ void AddFaces(List<tridata> &tri){
for(int i=0;i<tri.num;i++) { for(int i=0;i<tri.num;i++) {
new Triangle( new Triangle(
vertices[tri[i].v[0]], vertices[tri[i].v[0]],
vertices[tri[i].v[1]], vertices[tri[i].v[1]],
vertices[tri[i].v[2]] ); vertices[tri[i].v[2]] );
} }
} }
Vertex *MinimumCostEdge(){ Vertex *MinimumCostEdge(){
// Find the edge that when collapsed will affect model the least. // Find the edge that when collapsed will affect model the least.
// This funtion actually returns a Vertex, the second vertex // This funtion actually returns a Vertex, the second vertex
// of the edge (collapse candidate) is stored in the vertex data. // of the edge (collapse candidate) is stored in the vertex data.
// Serious optimization opportunity here: this function currently // Serious optimization opportunity here: this function currently
// does a sequential search through an unsorted list :-( // does a sequential search through an unsorted list :-(
// Our algorithm could be O(n*lg(n)) instead of O(n*n) // Our algorithm could be O(n*lg(n)) instead of O(n*n)
Vertex *mn=vertices[0]; Vertex *mn=vertices[0];
for(int i=0;i<vertices.num;i++) { for(int i=0;i<vertices.num;i++) {
if(vertices[i]->objdist < mn->objdist) { if(vertices[i]->objdist < mn->objdist) {
mn = vertices[i]; mn = vertices[i];
} }
} }
return mn; return mn;
} }
void ProgressiveMesh(List<Vector> &vert, List<tridata> &tri, void ProgressiveMesh(List<Vector> &vert, List<tridata> &tri,
List<int> &map, List<int> &permutation) List<int> &map, List<int> &permutation)
{ {
AddVertex(vert); // put input data into our data structures AddVertex(vert); // put input data into our data structures
AddFaces(tri); AddFaces(tri);
ComputeAllEdgeCollapseCosts(); // cache all edge collapse costs ComputeAllEdgeCollapseCosts(); // cache all edge collapse costs
permutation.SetSize(vertices.num); // allocate space permutation.SetSize(vertices.num); // allocate space
map.SetSize(vertices.num); // allocate space map.SetSize(vertices.num); // allocate space
// reduce the object down to nothing: // reduce the object down to nothing:
while(vertices.num > 0) { while(vertices.num > 0) {
// get the next vertex to collapse // get the next vertex to collapse
Vertex *mn = MinimumCostEdge(); Vertex *mn = MinimumCostEdge();
// keep track of this vertex, i.e. the collapse ordering // keep track of this vertex, i.e. the collapse ordering
permutation[mn->id]=vertices.num-1; permutation[mn->id]=vertices.num-1;
// keep track of vertex to which we collapse to // keep track of vertex to which we collapse to
map[vertices.num-1] = (mn->collapse)?mn->collapse->id:-1; map[vertices.num-1] = (mn->collapse)?mn->collapse->id:-1;
// Collapse this edge // Collapse this edge
Collapse(mn,mn->collapse); Collapse(mn,mn->collapse);
} }
// reorder the map list based on the collapse ordering // reorder the map list based on the collapse ordering
for(int i=0;i<map.num;i++) { for(int i=0;i<map.num;i++) {
map[i] = (map[i]==-1)?0:permutation[map[i]]; map[i] = (map[i]==-1)?0:permutation[map[i]];
} }
// The caller of this function should reorder their vertices // The caller of this function should reorder their vertices
// according to the returned "permutation". // according to the returned "permutation".
} }

View File

@ -23,8 +23,8 @@
class tridata { class tridata {
public: public:
int v[3]; // indices to vertex list int v[3]; // indices to vertex list
// texture and vertex normal info removed for this demo // texture and vertex normal info removed for this demo
}; };
void ProgressiveMesh(List<Vector> &vert, List<tridata> &tri, void ProgressiveMesh(List<Vector> &vert, List<tridata> &tri,

View File

@ -1,13 +1,14 @@
/* Copyright 1996, Viewpoint Datalabs Int'l, www.viewpoint.com, 1-800-DATASET */ /* Copyright 1996, Viewpoint Datalabs Int'l, www.viewpoint.com, 1-800-DATASET */
/* /*
# Usage Rights: You (the user) may use this model to help build cool personal # Usage Rights: You (the user) may use this model to help build
# vrml worlds, but please give us credit when you do ("3D model provided by # cool personal vrml worlds, but please give us credit when you do
# Viewpoint Datalabs, www,viewpoint.com"). Please don't sell it or use it to # ("3D model provided by Viewpoint Datalabs, www,viewpoint.com").
# make money indirectly. Don't redistribute it or put it on a web site except # Please don't sell it or use it to make money indirectly. Don't
# as a part of your personal, non-commerical vrml world. If you want to do a # redistribute it or put it on a web site except as a part of your
# commercial project, give us a call at 1-800-DATASET or visit www.viewpoint.com # personal, non-commerical vrml world. If you want to do a
# and we'll help you obtain the rights to do so. # commercial project, give us a call at 1-800-DATASET or visit
*/ # www.viewpoint.com and we'll help you obtain the rights to do so.
# */
/* /*
* Note that this data was put directly into the program * Note that this data was put directly into the program

View File

@ -1,4 +1,3 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <assert.h> #include <assert.h>
@ -15,23 +14,32 @@ float magnitude(Vector v) {
Vector normalize(Vector v) { Vector normalize(Vector v) {
float d=magnitude(v); float d=magnitude(v);
if (d==0) { if (d==0) {
printf("Cant normalize ZERO vector\n"); printf("Cant normalize ZERO vector\n");
assert(0); assert(0);
d=0.1f; d=0.1f;
} }
v.x/=d; v.x/=d;
v.y/=d; v.y/=d;
v.z/=d; v.z/=d;
return v; return v;
} }
Vector operator+(Vector v1,Vector v2) {return Vector(v1.x+v2.x,v1.y+v2.y,v1.z+v2.z);} Vector operator+(Vector v1,Vector v2)
Vector operator-(Vector v1,Vector v2) {return Vector(v1.x-v2.x,v1.y-v2.y,v1.z-v2.z);} {
return Vector(v1.x+v2.x,v1.y+v2.y,v1.z+v2.z);
}
Vector operator-(Vector v1,Vector v2)
{
return Vector(v1.x-v2.x,v1.y-v2.y,v1.z-v2.z);
}
Vector operator-(Vector v) {return Vector(-v.x,-v.y,-v.z);} Vector operator-(Vector v) {return Vector(-v.x,-v.y,-v.z);}
Vector operator*(Vector v1,float s) {return Vector(v1.x*s,v1.y*s,v1.z*s);} Vector operator*(Vector v1,float s) {return Vector(v1.x*s,v1.y*s,v1.z*s);}
Vector operator*(float s, Vector v1) {return Vector(v1.x*s,v1.y*s,v1.z*s);} Vector operator*(float s, Vector v1) {return Vector(v1.x*s,v1.y*s,v1.z*s);}
Vector operator/(Vector v1,float s) {return v1*(1.0f/s);} Vector operator/(Vector v1,float s) {return v1*(1.0f/s);}
float operator^(Vector v1,Vector v2) {return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;} float operator^(Vector v1,Vector v2)
{
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
Vector operator*(Vector v1,Vector v2) { Vector operator*(Vector v1,Vector v2) {
return Vector( return Vector(
v1.y * v2.z - v1.z*v2.y, v1.y * v2.z - v1.z*v2.y,
@ -39,70 +47,71 @@ Vector operator*(Vector v1,Vector v2) {
v1.x * v2.y - v1.y*v2.x); v1.x * v2.y - v1.y*v2.x);
} }
Vector planelineintersection(Vector n,float d,Vector p1,Vector p2){ Vector planelineintersection(Vector n,float d,Vector p1,Vector p2){
// returns the point where the line p1-p2 intersects the plane n&d // returns the point where the line p1-p2 intersects the plane n&d
Vector dif = p2-p1; Vector dif = p2-p1;
float dn= n^dif; float dn= n^dif;
float t = -(d+(n^p1) )/dn; float t = -(d+(n^p1) )/dn;
return p1 + (dif*t); return p1 + (dif*t);
} }
int concurrent(Vector a,Vector b) { int concurrent(Vector a,Vector b) {
return(a.x==b.x && a.y==b.y && a.z==b.z); return(a.x==b.x && a.y==b.y && a.z==b.z);
} }
// Matrix Implementation // Matrix Implementation
matrix transpose(matrix m) { matrix transpose(matrix m) {
return matrix( Vector(m.x.x,m.y.x,m.z.x), return matrix( Vector(m.x.x,m.y.x,m.z.x),
Vector(m.x.y,m.y.y,m.z.y), Vector(m.x.y,m.y.y,m.z.y),
Vector(m.x.z,m.y.z,m.z.z)); Vector(m.x.z,m.y.z,m.z.z));
} }
Vector operator*(matrix m,Vector v){ Vector operator*(matrix m,Vector v){
m=transpose(m); // since column ordered m=transpose(m); // since column ordered
return Vector(m.x^v,m.y^v,m.z^v); return Vector(m.x^v,m.y^v,m.z^v);
} }
matrix operator*(matrix m1,matrix m2){ matrix operator*(matrix m1,matrix m2){
m1=transpose(m1); m1=transpose(m1);
return matrix(m1*m2.x,m1*m2.y,m1*m2.z); return matrix(m1*m2.x,m1*m2.y,m1*m2.z);
} }
//Quaternion Implementation //Quaternion Implementation
Quaternion operator*(Quaternion a,Quaternion b) { Quaternion operator*(Quaternion a,Quaternion b) {
Quaternion c; Quaternion c;
c.r = a.r*b.r - a.x*b.x - a.y*b.y - a.z*b.z; c.r = a.r*b.r - a.x*b.x - a.y*b.y - a.z*b.z;
c.x = a.r*b.x + a.x*b.r + a.y*b.z - a.z*b.y; c.x = a.r*b.x + a.x*b.r + a.y*b.z - a.z*b.y;
c.y = a.r*b.y - a.x*b.z + a.y*b.r + a.z*b.x; c.y = a.r*b.y - a.x*b.z + a.y*b.r + a.z*b.x;
c.z = a.r*b.z + a.x*b.y - a.y*b.x + a.z*b.r; c.z = a.r*b.z + a.x*b.y - a.y*b.x + a.z*b.r;
return c; return c;
} }
Quaternion operator-(Quaternion q) { Quaternion operator-(Quaternion q) {
return Quaternion(q.r*-1,q.x,q.y,q.z); return Quaternion(q.r*-1,q.x,q.y,q.z);
} }
Quaternion operator*(Quaternion a,float b) { Quaternion operator*(Quaternion a,float b) {
return Quaternion(a.r*b, a.x*b, a.y*b, a.z*b); return Quaternion(a.r*b, a.x*b, a.y*b, a.z*b);
} }
Vector operator*(Quaternion q,Vector v) { Vector operator*(Quaternion q,Vector v) {
return q.getmatrix() * v; return q.getmatrix() * v;
} }
Vector operator*(Vector v,Quaternion q){ Vector operator*(Vector v,Quaternion q){
assert(0); // must multiply with the quat on the left assert(0); // must multiply with the quat on the left
return Vector(0.0f,0.0f,0.0f); return Vector(0.0f,0.0f,0.0f);
} }
Quaternion operator+(Quaternion a,Quaternion b) { Quaternion operator+(Quaternion a,Quaternion b) {
return Quaternion(a.r+b.r, a.x+b.x, a.y+b.y, a.z+b.z); return Quaternion(a.r+b.r, a.x+b.x, a.y+b.y, a.z+b.z);
} }
float operator^(Quaternion a,Quaternion b) { float operator^(Quaternion a,Quaternion b) {
return (a.r*b.r + a.x*b.x + a.y*b.y + a.z*b.z); return (a.r*b.r + a.x*b.x + a.y*b.y + a.z*b.z);
} }
Quaternion slerp(Quaternion a,Quaternion b,float interp){ Quaternion slerp(Quaternion a,Quaternion b,float interp){
if((a^b) <0.0) { if((a^b) <0.0) {
a.r=-a.r; a.r=-a.r;
a.x=-a.x; a.x=-a.x;
a.y=-a.y; a.y=-a.y;
a.z=-a.z; a.z=-a.z;
} }
float theta = float(acos(a^b)); float theta = float(acos(a^b));
if(theta==0.0f) { return(a);} if(theta==0.0f) { return(a);}
return a*float(sin(theta-interp*theta)/sin(theta)) + b*float(sin(interp*theta)/sin(theta)); return
a*float(sin(theta-interp*theta)/sin(theta))
+ b*float(sin(interp*theta)/sin(theta));
} }

View File

@ -13,9 +13,9 @@
class Vector { class Vector {
public: public:
float x,y,z; float x,y,z;
Vector(float _x=0.0,float _y=0.0,float _z=0.0){x=_x;y=_y;z=_z;}; Vector(float _x=0.0,float _y=0.0,float _z=0.0){x=_x;y=_y;z=_z;};
operator float *() { return &x;}; operator float *() { return &x;};
}; };
float magnitude(Vector v); float magnitude(Vector v);
@ -33,11 +33,11 @@ Vector planelineintersection(Vector n,float d,Vector p1,Vector p2);
class matrix{ class matrix{
public: public:
Vector x,y,z; Vector x,y,z;
matrix(){x=Vector(1.0f,0.0f,0.0f); matrix(){x=Vector(1.0f,0.0f,0.0f);
y=Vector(0.0f,1.0f,0.0f); y=Vector(0.0f,1.0f,0.0f);
z=Vector(0.0f,0.0f,1.0f);}; z=Vector(0.0f,0.0f,1.0f);};
matrix(Vector _x,Vector _y,Vector _z){x=_x;y=_y;z=_z;}; matrix(Vector _x,Vector _y,Vector _z){x=_x;y=_y;z=_z;};
}; };
matrix transpose(matrix m); matrix transpose(matrix m);
Vector operator*(matrix m,Vector v); Vector operator*(matrix m,Vector v);
@ -45,17 +45,30 @@ matrix operator*(matrix m1,matrix m2);
class Quaternion{ class Quaternion{
public: public:
float r,x,y,z; float r,x,y,z;
Quaternion(){x=y=z=0.0f;r=1.0f;}; Quaternion(){x=y=z=0.0f;r=1.0f;};
Quaternion(Vector v,float t){v=normalize(v);r=float(cos(t/2.0));v=v*float(sin(t/2.0));x=v.x;y=v.y;z=v.z;}; Quaternion(Vector v,float t){
Quaternion(float _r,float _x,float _y,float _z){r=_r;x=_x;y=_y;z=_z;}; v=normalize(v);
float angle(){return float(acos(r)*2.0);} r=float(cos(t/2.0));
Vector axis(){Vector a(x,y,z); return a*float(1/sin(angle()/2.0));} v=v*float(sin(t/2.0));
Vector xdir(){return Vector(1-2*(y*y+z*z), 2*(x*y+r*z), 2*(x*z-r*y));} x=v.x;
Vector ydir(){return Vector( 2*(x*y-r*z),1-2*(x*x+z*z), 2*(y*z+r*x));} y=v.y;
Vector zdir(){return Vector( 2*(x*z+r*y), 2*(y*z-r*x),1-2*(x*x+y*y));} z=v.z;
matrix getmatrix(){return matrix(xdir(),ydir(),zdir());} };
//operator matrix(){return getmatrix();} Quaternion(float _r,float _x,float _y,float _z){r=_r;x=_x;y=_y;z=_z;};
float angle(){return float(acos(r)*2.0);}
Vector axis(){Vector a(x,y,z); return a*float(1/sin(angle()/2.0));}
Vector xdir(){
return Vector(1-2*(y*y+z*z), 2*(x*y+r*z), 2*(x*z-r*y));
}
Vector ydir(){
return Vector( 2*(x*y-r*z),1-2*(x*x+z*z), 2*(y*z+r*x));
}
Vector zdir(){
return Vector( 2*(x*z+r*y), 2*(y*z-r*x),1-2*(x*x+y*y));
}
matrix getmatrix(){return matrix(xdir(),ydir(),zdir());}
//operator matrix(){return getmatrix();}
}; };
Quaternion operator-(Quaternion q); Quaternion operator-(Quaternion q);
Quaternion operator*(Quaternion a,Quaternion b); Quaternion operator*(Quaternion a,Quaternion b);

View File

@ -1,4 +1,3 @@
/* /*
* Polygon Reduction Demo by Stan Melax (c) 1998 * Polygon Reduction Demo by Stan Melax (c) 1998
* Permission to use any of this code wherever you want is granted.. * Permission to use any of this code wherever you want is granted..
@ -22,9 +21,9 @@
*/ */
#include <windows.h> /* must include this before GL/gl.h */ #include <windows.h> /* must include this before GL/gl.h */
#include <GL/gl.h> /* OpenGL header file */ #include <GL/gl.h> /* OpenGL header file */
#include <GL/glu.h> /* OpenGL utilities header file */ #include <GL/glu.h> /* OpenGL utilities header file */
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/timeb.h> #include <sys/timeb.h>
@ -42,114 +41,115 @@ extern Quaternion model_orientation; // orientation of bunny
// Global Variables // Global Variables
float DeltaT = 0.1f; float DeltaT = 0.1f;
float FPS; float FPS;
int Width = 512; int Width = 512;
int Height = 512; int Height = 512;
int MouseX = 0; int MouseX = 0;
int MouseY = 0; int MouseY = 0;
Vector MouseVector; // 3D direction mouse points Vector MouseVector; // 3D direction mouse points
Vector OldMouseVector; Vector OldMouseVector;
int MouseState=0; // true iff left button down int MouseState=0; // true iff left button down
float ViewAngle=45.0f; float ViewAngle=45.0f;
HDC hDC; /* device context */ HDC hDC; /* device context */
HPALETTE hPalette = 0; /* custom palette (if needed) */ HPALETTE hPalette = 0; /* custom palette (if needed) */
void CalcFPSDeltaT(){ void CalcFPSDeltaT(){
static int timeinit=0; static int timeinit=0;
static int start,start2,current,last; static int start,start2,current,last;
static int frame=0, frame2=0; static int frame=0, frame2=0;
if(!timeinit){ if(!timeinit){
frame=0; frame=0;
start=timeGetTime(); start=timeGetTime();
timeinit=1; timeinit=1;
} }
frame++; frame++;
frame2++; frame2++;
current=timeGetTime(); // found in winmm.lib current=timeGetTime(); // found in winmm.lib
double dif=(double)(current-start)/CLOCKS_PER_SEC; double dif=(double)(current-start)/CLOCKS_PER_SEC;
double rv = (dif)? (double)frame/(double)dif:-1.0; double rv = (dif)? (double)frame/(double)dif:-1.0;
if(dif>2.0 && frame >10) { if(dif>2.0 && frame >10) {
start = start2; start = start2;
frame = frame2; frame = frame2;
start2 = timeGetTime(); start2 = timeGetTime();
frame2 = 0; frame2 = 0;
} }
DeltaT = (float)(current-last)/CLOCKS_PER_SEC; DeltaT = (float)(current-last)/CLOCKS_PER_SEC;
if(current==last) { if(current==last) {
DeltaT = 0.1f/CLOCKS_PER_SEC; // it just cant be 0 DeltaT = 0.1f/CLOCKS_PER_SEC; // it just cant be 0
} }
// if(DeltaT>1.0) DeltaT=1.0; // if(DeltaT>1.0) DeltaT=1.0;
FPS = (float)rv; FPS = (float)rv;
last = current; last = current;
} }
void ComputeMouseVector(){ void ComputeMouseVector(){
OldMouseVector=MouseVector; OldMouseVector=MouseVector;
float spread = (float)tan(ViewAngle/2*3.14/180); float spread = (float)tan(ViewAngle/2*3.14/180);
float y = spread * ((Height-MouseY)-Height/2.0f) /(Height/2.0f); float y = spread * ((Height-MouseY)-Height/2.0f) /(Height/2.0f);
float x = spread * (MouseX-Width/2.0f) /(Height/2.0f); float x = spread * (MouseX-Width/2.0f) /(Height/2.0f);
Vector v(x ,y,-1); Vector v(x ,y,-1);
// v=UserOrientation *v; // v=UserOrientation *v;
v=normalize(v); v=normalize(v);
MouseVector = v; MouseVector = v;
} }
Quaternion VirtualTrackBall(Vector cop,Vector cor,Vector dir1,Vector dir2) { Quaternion VirtualTrackBall(Vector cop,Vector cor,Vector dir1,Vector dir2) {
// Implement track ball functionality to spin stuf on the screen // Implement track ball functionality to spin stuf on the screen
// cop center of projection // cop center of projection
// cor center of rotation // cor center of rotation
// dir1 old mouse direction // dir1 old mouse direction
// dir2 new mouse direction // dir2 new mouse direction
// pretend there is a sphere around cor. Then find the points // pretend there is a sphere around cor. Then find the points
// where dir1 and dir2 intersect that sphere. Find the // where dir1 and dir2 intersect that sphere. Find the
// rotation that takes the first point to the second. // rotation that takes the first point to the second.
float m; float m;
// compute plane // compute plane
Vector nrml = cor - cop; Vector nrml = cor - cop;
float fudgefactor = 1.0f/(magnitude(nrml) * 0.25f); // since trackball proportional to distance from cop // since trackball proportional to distance from cop
nrml = normalize(nrml); float fudgefactor = 1.0f/(magnitude(nrml) * 0.25f);
float dist = -(nrml^cor); nrml = normalize(nrml);
Vector u= planelineintersection(nrml,dist,cop,cop+dir1); float dist = -(nrml^cor);
u=u-cor; Vector u= planelineintersection(nrml,dist,cop,cop+dir1);
u=u*fudgefactor; u=u-cor;
m= magnitude(u); u=u*fudgefactor;
if(m>1) {u=u*1.0f/m;} m= magnitude(u);
else { if(m>1) {u=u*1.0f/m;}
u=u - (nrml * (float)sqrt(1-m*m)); else {
} u=u - (nrml * (float)sqrt(1-m*m));
Vector v= planelineintersection(nrml,dist,cop,cop+dir2); }
v=v-cor; Vector v= planelineintersection(nrml,dist,cop,cop+dir2);
v=v*fudgefactor; v=v-cor;
m= magnitude(v); v=v*fudgefactor;
if(m>1) {v=v*1.0f/m;} m= magnitude(v);
else { if(m>1) {v=v*1.0f/m;}
v=v - (nrml * (float)sqrt(1-m*m)); else {
} v=v - (nrml * (float)sqrt(1-m*m));
Vector axis = u*v; }
float angle; Vector axis = u*v;
m=magnitude(axis); float angle;
if(m>1)m=1; // avoid potential floating point error m=magnitude(axis);
Quaternion q(Vector(1.0f,0.0f,0.0f),0.0f); if(m>1)m=1; // avoid potential floating point error
if(m>0 && (angle=(float)asin(m))>3.14/180) { Quaternion q(Vector(1.0f,0.0f,0.0f),0.0f);
axis = normalize(axis); if(m>0 && (angle=(float)asin(m))>3.14/180) {
q=Quaternion(axis,angle); axis = normalize(axis);
} q=Quaternion(axis,angle);
return q; }
return q;
} }
void SpinIt(){ void SpinIt(){
// Change the orientation of the bunny according to mouse drag // Change the orientation of the bunny according to mouse drag
Quaternion q=VirtualTrackBall(Vector(0,0,0),model_position, Quaternion q=VirtualTrackBall(Vector(0,0,0),model_position,
OldMouseVector,MouseVector); OldMouseVector,MouseVector);
model_orientation=q*model_orientation; model_orientation=q*model_orientation;
} }
void Reshape(int width, int height){ void Reshape(int width, int height){
// called initially and when the window changes size // called initially and when the window changes size
Width=width; Width=width;
Height=height; Height=height;
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
@ -159,109 +159,109 @@ void Reshape(int width, int height){
} }
void PrintStats(){ void PrintStats(){
char buf[1024];buf[0]='\0'; char buf[1024];buf[0]='\0';
sprintf(buf,"FPS: %5.2f ",FPS); sprintf(buf,"FPS: %5.2f ",FPS);
PostString(buf,0,-1,0); PostString(buf,0,-1,0);
} }
void Display(){ void Display(){
// main drawing routine - called every frame // main drawing routine - called every frame
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
// camera at default (zero) position and orientation // camera at default (zero) position and orientation
RenderModel(); RenderModel();
PrintStats(); PrintStats();
glLoadIdentity(); glLoadIdentity();
RenderStrings(); RenderStrings();
glPopMatrix(); glPopMatrix();
glFlush(); glFlush();
SwapBuffers(hDC); /* nop if singlebuffered */ SwapBuffers(hDC); /* nop if singlebuffered */
} }
LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
static PAINTSTRUCT ps; static PAINTSTRUCT ps;
static GLboolean left = GL_FALSE; /* left button currently down? */ static GLboolean left = GL_FALSE; /* left button currently down? */
static GLboolean right = GL_FALSE; /* right button currently down? */ static GLboolean right = GL_FALSE; /* right button currently down? */
static int omx, omy, mx, my; static int omx, omy, mx, my;
switch(uMsg) { switch(uMsg) {
case WM_PAINT: case WM_PAINT:
BeginPaint(hWnd, &ps); BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
return 0; return 0;
case WM_SIZE: case WM_SIZE:
Reshape(LOWORD(lParam), HIWORD(lParam)); Reshape(LOWORD(lParam), HIWORD(lParam));
PostMessage(hWnd, WM_PAINT, 0, 0); PostMessage(hWnd, WM_PAINT, 0, 0);
return 0; return 0;
case WM_CHAR: case WM_CHAR:
switch (wParam) { switch (wParam) {
case 27: /* ESC key */ case 27: /* ESC key */
PostQuitMessage(0); PostQuitMessage(0);
break; break;
} }
return 0; return 0;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
/* if we don't set the capture we won't get mouse move /* if we don't set the capture we won't get mouse move
messages when the mouse moves outside the window. */ messages when the mouse moves outside the window. */
SetCapture(hWnd); SetCapture(hWnd);
MouseX = LOWORD(lParam); MouseX = LOWORD(lParam);
MouseY = HIWORD(lParam); MouseY = HIWORD(lParam);
ComputeMouseVector(); ComputeMouseVector();
MouseState = 1; MouseState = 1;
return 0; return 0;
case WM_LBUTTONUP: case WM_LBUTTONUP:
MouseX = LOWORD(lParam); MouseX = LOWORD(lParam);
MouseY = HIWORD(lParam); MouseY = HIWORD(lParam);
if(MouseX & 1 << 15) MouseX -= (1 << 16); if(MouseX & 1 << 15) MouseX -= (1 << 16);
if(MouseY & 1 << 15) MouseY -= (1 << 16); if(MouseY & 1 << 15) MouseY -= (1 << 16);
ComputeMouseVector(); ComputeMouseVector();
if(MouseState) SpinIt(); if(MouseState) SpinIt();
MouseState=0; MouseState=0;
/* remember to release the capture when we are finished. */ /* remember to release the capture when we are finished. */
ReleaseCapture(); ReleaseCapture();
return 0; return 0;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
MouseX = LOWORD(lParam); MouseX = LOWORD(lParam);
MouseY = HIWORD(lParam); MouseY = HIWORD(lParam);
/* Win32 is pretty braindead about the x, y position that /* Win32 is pretty braindead about the x, y position that
it returns when the mouse is off the left or top edge it returns when the mouse is off the left or top edge
of the window (due to them being unsigned). therefore, of the window (due to them being unsigned). therefore,
roll the Win32's 0..2^16 pointer co-ord range to the roll the Win32's 0..2^16 pointer co-ord range to the
more amenable (and useful) 0..+/-2^15. */ more amenable (and useful) 0..+/-2^15. */
if(MouseX & 1 << 15) MouseX -= (1 << 16); if(MouseX & 1 << 15) MouseX -= (1 << 16);
if(MouseY & 1 << 15) MouseY -= (1 << 16); if(MouseY & 1 << 15) MouseY -= (1 << 16);
ComputeMouseVector(); ComputeMouseVector();
if(MouseState) SpinIt(); if(MouseState) SpinIt();
return 0; return 0;
case WM_PALETTECHANGED: case WM_PALETTECHANGED:
if (hWnd == (HWND)wParam) break; if (hWnd == (HWND)wParam) break;
/* fall through to WM_QUERYNEWPALETTE */ /* fall through to WM_QUERYNEWPALETTE */
case WM_QUERYNEWPALETTE: case WM_QUERYNEWPALETTE:
if (hPalette) { if (hPalette) {
UnrealizeObject(hPalette); UnrealizeObject(hPalette);
SelectPalette(hDC, hPalette, FALSE); SelectPalette(hDC, hPalette, FALSE);
RealizePalette(hDC); RealizePalette(hDC);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
case WM_CLOSE: case WM_CLOSE:
PostQuitMessage(0); PostQuitMessage(0);
return 0; return 0;
} }
return DefWindowProc(hWnd, uMsg, wParam, lParam); return DefWindowProc(hWnd, uMsg, wParam, lParam);
} }
HWND CreateOpenGLWindow(char* title) HWND CreateOpenGLWindow(char* title)
{ {
// make a double-buffered, rgba, opengl window // make a double-buffered, rgba, opengl window
int n, pf; int n, pf;
HWND hWnd; HWND hWnd;
WNDCLASS wc; WNDCLASS wc;
@ -271,33 +271,35 @@ HWND CreateOpenGLWindow(char* title)
/* only register the window class once - use hInstance as a flag. */ /* only register the window class once - use hInstance as a flag. */
if (!hInstance) { if (!hInstance) {
hInstance = GetModuleHandle(NULL); hInstance = GetModuleHandle(NULL);
wc.style = CS_OWNDC; wc.style = CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)WindowProc; wc.lpfnWndProc = (WNDPROC)WindowProc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = 0; wc.cbWndExtra = 0;
wc.hInstance = hInstance; wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL; wc.hbrBackground = NULL;
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
wc.lpszClassName = "OpenGL"; wc.lpszClassName = "OpenGL";
if (!RegisterClass(&wc)) { if (!RegisterClass(&wc)) {
MessageBox(NULL, "RegisterClass() failed: " MessageBox(NULL, "RegisterClass() failed: "
"Cannot register window class.", "Error", MB_OK); "Cannot register window class.",
return NULL; "Error", MB_OK);
} return NULL;
}
} }
hWnd = CreateWindow("OpenGL", title, WS_OVERLAPPEDWINDOW | hWnd = CreateWindow("OpenGL", title, WS_OVERLAPPEDWINDOW |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0,0,Width,Height, NULL, NULL, hInstance, NULL); 0,0,Width,Height, NULL, NULL, hInstance, NULL);
if (hWnd == NULL) { if (hWnd == NULL) {
MessageBox(NULL, "CreateWindow() failed: Cannot create a window.", MessageBox(NULL,
"Error", MB_OK); "CreateWindow() failed: Cannot create a window.",
return NULL; "Error", MB_OK);
return NULL;
} }
hDC = GetDC(hWnd); hDC = GetDC(hWnd);
@ -307,84 +309,90 @@ HWND CreateOpenGLWindow(char* title)
memset(&pfd, 0, sizeof(pfd)); memset(&pfd, 0, sizeof(pfd));
pfd.nSize = sizeof(pfd); pfd.nSize = sizeof(pfd);
pfd.nVersion = 1; pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.dwFlags = PFD_DRAW_TO_WINDOW
| PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA; pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cDepthBits = 32; pfd.cDepthBits = 32;
pfd.cColorBits = 32; pfd.cColorBits = 32;
pf = ChoosePixelFormat(hDC, &pfd); pf = ChoosePixelFormat(hDC, &pfd);
if (pf == 0) { if (pf == 0) {
MessageBox(NULL, "ChoosePixelFormat() failed: " MessageBox(NULL, "ChoosePixelFormat() failed: "
"Cannot find a suitable pixel format.", "Error", MB_OK); "Cannot find a suitable pixel format.",
return 0; "Error", MB_OK);
return 0;
} }
if (SetPixelFormat(hDC, pf, &pfd) == FALSE) { if (SetPixelFormat(hDC, pf, &pfd) == FALSE) {
MessageBox(NULL, "SetPixelFormat() failed: " MessageBox(NULL, "SetPixelFormat() failed: "
"Cannot set format specified.", "Error", MB_OK); "Cannot set format specified.", "Error", MB_OK);
return 0; return 0;
} }
DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (pfd.dwFlags & PFD_NEED_PALETTE || if (pfd.dwFlags & PFD_NEED_PALETTE ||
pfd.iPixelType == PFD_TYPE_COLORINDEX) { pfd.iPixelType == PFD_TYPE_COLORINDEX) {
n = 1 << pfd.cColorBits; n = 1 << pfd.cColorBits;
if (n > 256) n = 256; if (n > 256) n = 256;
lpPal = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) + lpPal = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) +
sizeof(PALETTEENTRY) * n); sizeof(PALETTEENTRY) * n);
memset(lpPal, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n); memset(lpPal, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n);
lpPal->palVersion = 0x300; lpPal->palVersion = 0x300;
lpPal->palNumEntries = n; lpPal->palNumEntries = n;
GetSystemPaletteEntries(hDC, 0, n, &lpPal->palPalEntry[0]); GetSystemPaletteEntries(hDC, 0, n, &lpPal->palPalEntry[0]);
/* if the pixel type is RGBA, then we want to make an RGB ramp, /* if the pixel type is RGBA, then we want to make an RGB ramp,
otherwise (color index) set individual colors. */ otherwise (color index) set individual colors. */
if (pfd.iPixelType == PFD_TYPE_RGBA) { if (pfd.iPixelType == PFD_TYPE_RGBA) {
int redMask = (1 << pfd.cRedBits) - 1; int redMask = (1 << pfd.cRedBits) - 1;
int greenMask = (1 << pfd.cGreenBits) - 1; int greenMask = (1 << pfd.cGreenBits) - 1;
int blueMask = (1 << pfd.cBlueBits) - 1; int blueMask = (1 << pfd.cBlueBits) - 1;
int i; int i;
/* fill in the entries with an RGB color ramp. */ /* fill in the entries with an RGB color ramp. */
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {
lpPal->palPalEntry[i].peRed = lpPal->palPalEntry[i].peRed =
(((i >> pfd.cRedShift) & redMask) * 255)/redMask; (((i >> pfd.cRedShift) & redMask) * 255)
lpPal->palPalEntry[i].peGreen = /redMask;
(((i >> pfd.cGreenShift) & greenMask) * 255)/greenMask; lpPal->palPalEntry[i].peGreen =
lpPal->palPalEntry[i].peBlue = (((i >> pfd.cGreenShift) & greenMask) * 255)
(((i >> pfd.cBlueShift) & blueMask) * 255)/blueMask; /greenMask;
lpPal->palPalEntry[i].peFlags = 0; lpPal->palPalEntry[i].peBlue =
} (((i >> pfd.cBlueShift) & blueMask) * 255)
} else { /blueMask;
lpPal->palPalEntry[0].peRed = 0; lpPal->palPalEntry[i].peFlags = 0;
lpPal->palPalEntry[0].peGreen = 0; }
lpPal->palPalEntry[0].peBlue = 0; } else {
lpPal->palPalEntry[0].peFlags = PC_NOCOLLAPSE; lpPal->palPalEntry[0].peRed = 0;
lpPal->palPalEntry[1].peRed = 255; lpPal->palPalEntry[0].peGreen = 0;
lpPal->palPalEntry[1].peGreen = 0; lpPal->palPalEntry[0].peBlue = 0;
lpPal->palPalEntry[1].peBlue = 0; lpPal->palPalEntry[0].peFlags = PC_NOCOLLAPSE;
lpPal->palPalEntry[1].peFlags = PC_NOCOLLAPSE; lpPal->palPalEntry[1].peRed = 255;
lpPal->palPalEntry[2].peRed = 0; lpPal->palPalEntry[1].peGreen = 0;
lpPal->palPalEntry[2].peGreen = 255; lpPal->palPalEntry[1].peBlue = 0;
lpPal->palPalEntry[2].peBlue = 0; lpPal->palPalEntry[1].peFlags = PC_NOCOLLAPSE;
lpPal->palPalEntry[2].peFlags = PC_NOCOLLAPSE; lpPal->palPalEntry[2].peRed = 0;
lpPal->palPalEntry[3].peRed = 0; lpPal->palPalEntry[2].peGreen = 255;
lpPal->palPalEntry[3].peGreen = 0; lpPal->palPalEntry[2].peBlue = 0;
lpPal->palPalEntry[3].peBlue = 255; lpPal->palPalEntry[2].peFlags = PC_NOCOLLAPSE;
lpPal->palPalEntry[3].peFlags = PC_NOCOLLAPSE; lpPal->palPalEntry[3].peRed = 0;
} lpPal->palPalEntry[3].peGreen = 0;
lpPal->palPalEntry[3].peBlue = 255;
lpPal->palPalEntry[3].peFlags = PC_NOCOLLAPSE;
}
hPalette = CreatePalette(lpPal); hPalette = CreatePalette(lpPal);
if (hPalette) { if (hPalette) {
SelectPalette(hDC, hPalette, FALSE); SelectPalette(hDC, hPalette, FALSE);
RealizePalette(hDC); RealizePalette(hDC);
} }
free(lpPal); free(lpPal);
} }
ReleaseDC(hDC, hWnd); ReleaseDC(hDC, hWnd);
@ -392,46 +400,47 @@ HWND CreateOpenGLWindow(char* title)
} }
int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst,
LPSTR lpszCmdLine, int nCmdShow) LPSTR lpszCmdLine, int nCmdShow)
{ {
HGLRC hRC; /* opengl context */ HGLRC hRC; /* opengl context */
HWND hWnd; /* window */ HWND hWnd; /* window */
MSG msg; /* message */ MSG msg; /* message */
// InitModel() initializes some data structures and // InitModel() initializes some data structures and
// does the progressive mesh polygon reduction algorithm // does the progressive mesh polygon reduction algorithm
// on the model. // on the model.
CalcFPSDeltaT(); // to time the algorithm CalcFPSDeltaT(); // to time the algorithm
InitModel(); InitModel();
CalcFPSDeltaT(); CalcFPSDeltaT();
hWnd = CreateOpenGLWindow("bunnylod by Stan Melax"); hWnd = CreateOpenGLWindow("bunnylod by Stan Melax");
if (hWnd == NULL) exit(1); if (hWnd == NULL) exit(1);
hDC = GetDC(hWnd); hDC = GetDC(hWnd);
hRC = wglCreateContext(hDC); hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC); wglMakeCurrent(hDC, hRC);
ShowWindow(hWnd, nCmdShow); ShowWindow(hWnd, nCmdShow);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
PostString("Demo by Stan Melax (c)1998",5,-5,20); PostString("Demo by Stan Melax (c)1998",5,-5,20);
PostString("Model by Viewpoint Datalabs (c)1996",5,-4,20); PostString("Model by Viewpoint Datalabs (c)1996",5,-4,20);
char buf[128]; char buf[128];
PostString("Mesh Reduction Algorithm (non-optimized)",1,0,5); PostString("Mesh Reduction Algorithm (non-optimized)",1,0,5);
sprintf(buf,"was executed in %5.3f seconds",DeltaT); sprintf(buf,"was executed in %5.3f seconds",DeltaT);
PostString(buf,2,1,6); PostString(buf,2,1,6);
while (1) { while (1) {
while(PeekMessage(&msg, hWnd, 0, 0, PM_NOREMOVE)) { while(PeekMessage(&msg, hWnd, 0, 0, PM_NOREMOVE)) {
if(GetMessage(&msg, hWnd, 0, 0)) { if(GetMessage(&msg, hWnd, 0, 0)) {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} else { } else {
goto quit; // This 'goto' was in the sample code // This 'goto' was in the sample code
} goto quit;
} }
CalcFPSDeltaT(); }
Display(); CalcFPSDeltaT();
Display();
} }
quit: quit:

View File

@ -364,7 +364,8 @@ int main(int argc, char *argv[])
Info<< "writing surfMesh again well: " << surfOut.objectPath() << endl; Info<< "writing surfMesh again well: " << surfOut.objectPath()
<< endl;
surfOut.write(); surfOut.write();
// write directly // write directly

View File

@ -88,7 +88,8 @@ int main(int argc, char *argv[])
// - explicitly named patches only (-patches (at your option) // - explicitly named patches only (-patches (at your option)
// - all patches (default in sequential mode) // - all patches (default in sequential mode)
// - all non-processor patches (default in parallel mode) // - all non-processor patches (default in parallel mode)
// - all non-processor patches (sequential mode, -excludeProcPatches (at your option) // - all non-processor patches (sequential mode, -excludeProcPatches
// (at your option)
// Construct table of patches to include. // Construct table of patches to include.
const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); const polyBoundaryMesh& bMesh = mesh.boundaryMesh();

View File

@ -481,8 +481,8 @@ label sharedFace
} }
// Calculate (inward pointing) normals on edges shared by faces in faceToEdge and // Calculate (inward pointing) normals on edges shared by faces in
// averages them to pointNormals. // faceToEdge and averages them to pointNormals.
void calcPointVecs void calcPointVecs
( (
const triSurface& surf, const triSurface& surf,
@ -696,8 +696,9 @@ int main(int argc, char *argv[])
boolList borderEdge(surf.nEdges(), false); boolList borderEdge(surf.nEdges(), false);
markBorderEdges(debug, surf, borderEdge); markBorderEdges(debug, surf, borderEdge);
// Points on two sides connected to borderEdges are called borderPoints and // Points on two sides connected to borderEdges are called
// will be duplicated. borderPoint contains label of newly introduced vertex. // borderPoints and will be duplicated. borderPoint contains label
// of newly introduced vertex.
labelList borderPoint(surf.nPoints(), -1); labelList borderPoint(surf.nPoints(), -1);
markBorderPoints(debug, surf, borderEdge, borderPoint); markBorderPoints(debug, surf, borderEdge, borderPoint);

View File

@ -39,9 +39,10 @@ Description
(baseType,thisType,memberFunction,argNames,lookup,functionPtr) \ (baseType,thisType,memberFunction,argNames,lookup,functionPtr) \
\ \
/* Add the thisType memberFunction to the table, find by lookup name */ \ /* Add the thisType memberFunction to the table, find by lookup name */ \
baseType::add##memberFunction##argNames##StaticMemberFunctionToTable<thisType> \ baseType::add##memberFunction##argNames## \
add_##lookup##_##thisType##memberFunction##argNames##StaticMemberFunctionTo##baseType##Table_\ StaticMemberFunctionToTable<thisType> \
(#lookup, functionPtr) add_##lookup##_##thisType##memberFunction##argNames## \
StaticMemberFunctionTo##baseType##Table_(#lookup, functionPtr)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,20 +28,23 @@ License
OpenFOAM is a free, open source CFD software package produced by OpenFOAM is a free, open source CFD software package produced by
a commercial company, a commercial company,
<a href="http://www.openfoam.com/about">OpenCFD Ltd</a>. <a href="http://www.openfoam.com/about">OpenCFD Ltd</a>.
It has a It has a large user base across most areas of engineering and
large user base across most areas of engineering and science, science, from both commercial and academic organisations.
from both commercial and academic organisations. OpenFOAM has an OpenFOAM has an extensive range of features to solve anything from
extensive range of features to solve anything from complex fluid complex fluid flows involving chemical reactions, turbulence and
flows involving chemical reactions, turbulence and heat transfer, heat transfer, to solid dynamics and electromagnetics.
to solid dynamics and electromagnetics.
<a href="http://www.openfoam.com/features">More ...</a> <a href="http://www.openfoam.com/features">More ...</a>
@section users Our commitment to the users @section users Our commitment to the users
OpenFOAM comes with full commercial support from OpenCFD, including OpenFOAM comes with full commercial support from OpenCFD, including
<a href="http://www.openfoam.com/support/software.php">software support</a>, <a href="http://www.openfoam.com/support/software.php">
<a href="http://www.openfoam.com/support/development.php">contracted developments</a> software support</a>,
and a programme of <a href="http://www.openfoam.com/training/">training courses</a>. <a href="http://www.openfoam.com/support/development.php">
contracted developments</a>
and a programme of
<a href="http://www.openfoam.com/training/">
training courses</a>.
These activities fund the development, maintenance and release of These activities fund the development, maintenance and release of
OpenFOAM to make it an extremely viable commercial open source product. OpenFOAM to make it an extremely viable commercial open source product.
@ -49,7 +52,8 @@ License
OpenCFD is committed to open source software, continually developing and OpenCFD is committed to open source software, continually developing and
maintaining OpenFOAM under the maintaining OpenFOAM under the
<a href="http://www.gnu.org/copyleft/gpl.html">GNU General Public Licence</a>. <a href="http://www.gnu.org/copyleft/gpl.html">
GNU General Public Licence</a>.
OpenFOAM will <strong>always</strong> be free of charge and open source. OpenFOAM will <strong>always</strong> be free of charge and open source.
In addition, we endeavour to support other viable open source initiatives In addition, we endeavour to support other viable open source initiatives
that will benefit science and engineering. that will benefit science and engineering.

View File

@ -43,7 +43,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class processorCyclicGAMGInterfaceField Declaration Class processorCyclicGAMGInterfaceField Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class processorCyclicGAMGInterfaceField class processorCyclicGAMGInterfaceField
@ -65,7 +65,10 @@ class processorCyclicGAMGInterfaceField
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
processorCyclicGAMGInterfaceField(const processorCyclicGAMGInterfaceField&); processorCyclicGAMGInterfaceField
(
const processorCyclicGAMGInterfaceField&
);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const processorCyclicGAMGInterfaceField&); void operator=(const processorCyclicGAMGInterfaceField&);

View File

@ -54,8 +54,9 @@ addToRunTimeSelectionTable
//void Foam::processorCyclicPointPatch::initGeometry(PstreamBuffers& pBufs) //void Foam::processorCyclicPointPatch::initGeometry(PstreamBuffers& pBufs)
//{ //{
// // Algorithm: // // Algorithm:
// // Depending on whether the patch is a master or a slave, get the primitive // // Depending on whether the patch is a master or a slave, get the
// // patch points and filter away the points from the global patch. // // primitive patch points and filter away the points from the
// // global patch.
// //
// if (isMaster()) // if (isMaster())
// { // {
@ -152,7 +153,8 @@ addToRunTimeSelectionTable
//{ //{
// if (debug) // if (debug)
// { // {
// Info<< "processorCyclicPointPatch::initPatchPatchPoints(PstreamBuffers&) : " // Info<< "processorCyclicPointPatch::"
// << "initPatchPatchPoints(PstreamBuffers&) : "
// << "constructing patch-patch points" // << "constructing patch-patch points"
// << endl; // << endl;
// } // }
@ -204,8 +206,8 @@ addToRunTimeSelectionTable
// //
// if (iter != patchPointSet.end()) // if (iter != patchPointSet.end())
// { // {
// // If it is shared initialise the patchPatchPoints for this // // If it is shared initialise the patchPatchPoints for
// // patch // // this patch
// if (!patchPatchPoints[patchi].size()) // if (!patchPatchPoints[patchi].size())
// { // {
// patchPatchPoints[patchi].setSize(ppmp.size()); // patchPatchPoints[patchi].setSize(ppmp.size());
@ -244,7 +246,10 @@ addToRunTimeSelectionTable
//} //}
// //
// //
//void Foam::processorCyclicPointPatch::calcPatchPatchPoints(PstreamBuffers& pBufs) //void Foam::processorCyclicPointPatch::calcPatchPatchPoints
//(
// PstreamBuffers& pBufs
//)
//{ //{
// // Get the patchPatchPoints from the neighbouring processor // // Get the patchPatchPoints from the neighbouring processor
// UIPstream fromNeighbProc(neighbProcNo(), pBufs); // UIPstream fromNeighbProc(neighbProcNo(), pBufs);
@ -264,7 +269,10 @@ addToRunTimeSelectionTable
// // separate. // // separate.
// if (nbrNPoints != ppmp.size()) // if (nbrNPoints != ppmp.size())
// { // {
// WarningIn("processorCyclicPointPatch::calcPatchPatchPoints(PstreamBuffers&)") // WarningIn
// (
// "processorCyclicPointPatch::calcPatchPatchPoints(PstreamBuffers&)"
// )
// << "Processor patch " << name() // << "Processor patch " << name()
// << " has " << ppmp.size() << " points; coupled patch has " // << " has " << ppmp.size() << " points; coupled patch has "
// << nbrNPoints << " points." << endl // << nbrNPoints << " points." << endl
@ -280,9 +288,11 @@ addToRunTimeSelectionTable
// forAll(patchPatchPoints, patchi) // forAll(patchPatchPoints, patchi)
// { // {
// const labelList& patchPoints = patchPatchPoints[patchi]; // const labelList& patchPoints = patchPatchPoints[patchi];
// const List<vector>& patchPointNormals = patchPatchPointNormals[patchi]; // const List<vector>& patchPointNormals =
// patchPatchPointNormals[patchi];
// //
// // If there are potentially shared points for the patch being considered // // If there are potentially shared points for the patch being
// // considered
// if (patchPoints.size()) // if (patchPoints.size())
// { // {
// // Get the current meshPoints list for the patch // // Get the current meshPoints list for the patch
@ -351,7 +361,11 @@ addToRunTimeSelectionTable
//} //}
//void processorCyclicPointPatch::initMovePoints(PstreamBuffers&, const pointField&) //void processorCyclicPointPatch::initMovePoints
//(
// PstreamBuffers&,
// const pointField&
//)
//{} //{}
// //
// //

View File

@ -693,7 +693,8 @@ void Foam::meshReaders::STARCD::readBoundary(const fileName& inputName)
maxId = max(maxId, starRegion); maxId = max(maxId, starRegion);
if (patchType == "BAFF") // should actually be case-insensitive // should actually be case-insensitive
if (patchType == "BAFF")
{ {
nBafflePatches++; nBafflePatches++;
} }

View File

@ -140,7 +140,8 @@ public:
//- Return a Map of (id => names) selected by patterns //- Return a Map of (id => names) selected by patterns
Map<word> names(const UList<wordRe>& patterns) const; Map<word> names(const UList<wordRe>& patterns) const;
//- Return a Map of (id => name) for materialType (fluid | solid | shell) //- Return a Map of (id => name) for materialType
// (fluid | solid | shell)
Map<word> selectType(const word& materialType) const; Map<word> selectType(const word& materialType) const;
//- Return a Map of (id => name) for fluids //- Return a Map of (id => name) for fluids

View File

@ -1400,8 +1400,8 @@ Foam::polyDualMesh::polyDualMesh
polyMesh polyMesh
( (
mesh, mesh,
xferCopy(pointField()), // to prevent any warnings "points not allocated" xferCopy(pointField()),// to prevent any warnings "points not allocated"
xferCopy(faceList()), // to prevent any warnings "faces not allocated" xferCopy(faceList()), // to prevent any warnings "faces not allocated"
xferCopy(cellList()) xferCopy(cellList())
), ),
cellPoint_ cellPoint_
@ -1445,8 +1445,8 @@ Foam::polyDualMesh::polyDualMesh
polyMesh polyMesh
( (
mesh, mesh,
xferCopy(pointField()), // to prevent any warnings "points not allocated" xferCopy(pointField()),// to prevent any warnings "points not allocated"
xferCopy(faceList()), // to prevent any warnings "faces not allocated" xferCopy(faceList()), // to prevent any warnings "faces not allocated"
xferCopy(cellList()) xferCopy(cellList())
), ),
cellPoint_ cellPoint_

View File

@ -60,7 +60,11 @@
*sqrt *sqrt
( (
4.0*Vk 4.0*Vk
/(circleFraction*thickness*constant::mathematical::pi) /(
circleFraction
*thickness
*constant::mathematical::pi
)
); );
} }
break; break;

View File

@ -247,7 +247,8 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is)
WarningIn("MRFZone(const fvMesh&, Istream&)") WarningIn("MRFZone(const fvMesh&, Istream&)")
<< "Ignoring entry 'patches'\n" << "Ignoring entry 'patches'\n"
<< " By default all patches within the rotating region rotate.\n" << " By default all patches within the rotating region rotate.\n"
<< " Optionally supply excluded patches using 'nonRotatingPatches'." << " Optionally supply excluded patches "
<< "using 'nonRotatingPatches'."
<< endl; << endl;
} }

View File

@ -56,7 +56,10 @@ bool Foam::explicitSource::read(const dictionary& dict)
if (basicSource::read(dict)) if (basicSource::read(dict))
{ {
const dictionary& sourceDict = dict.subDict(name()); const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs = sourceDict.subDict(typeName + "Coeffs"); const dictionary& subDictCoeffs = sourceDict.subDict
(
typeName + "Coeffs"
);
setFieldData(subDictCoeffs.subDict("fieldData")); setFieldData(subDictCoeffs.subDict("fieldData"));
return true; return true;
} }

View File

@ -208,7 +208,10 @@ inline Foam::labelList& Foam::TimeActivatedExplicitSource<Type>::cells()
template<class Type> template<class Type>
inline Foam::List<typename Foam::TimeActivatedExplicitSource<Type>::fieldNameValuePair>& inline Foam::List
<
typename Foam::TimeActivatedExplicitSource<Type>::fieldNameValuePair
>&
Foam::TimeActivatedExplicitSource<Type>::fieldData() Foam::TimeActivatedExplicitSource<Type>::fieldData()
{ {
return fieldData_; return fieldData_;

View File

@ -179,9 +179,10 @@ processorCyclicFvPatchField<Type>::~processorCyclicFvPatchField()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//template<class Type> //template<class Type>
//tmp<Field<Type> > processorCyclicFvPatchField<Type>::patchNeighbourField() const //tmp<Field<Type> >
//processorCyclicFvPatchField<Type>::patchNeighbourField() const
//{ //{
// return *this; // return *this;
//} //}
// //
// //

View File

@ -46,7 +46,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class processorCyclicFvPatch Declaration Class processorCyclicFvPatch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Type> template<class Type>
@ -63,8 +63,12 @@ class processorCyclicFvPatchField
// Private Member Functions // Private Member Functions
// //- Get other patchfield // //- Get other patchfield
// const coupledFvPatchField<Type>& patchField(const label patchID) const; // const coupledFvPatchField<Type>& patchField
// (
// const label patchID
// ) const;
public: public:
//- Runtime type information //- Runtime type information
@ -261,7 +265,10 @@ public:
// const label start // const label start
// ) const // ) const
// { // {
// notImplemented("processorCyclicFvPatchField::initEvaluate(..)"); // notImplemented
// (
// "processorCyclicFvPatchField::initEvaluate(..)"
// );
// } // }
// //
// //- Evaluate the patch field. // //- Evaluate the patch field.
@ -292,7 +299,8 @@ public:
// { // {
// notImplemented // notImplemented
// ( // (
// "processorCyclicFvPatchField::initInterfaceMatrixUpdate(..)" // "processorCyclicFvPatchField::"
// "initInterfaceMatrixUpdate(..)"
// ); // );
// } // }
// //

View File

@ -381,7 +381,10 @@ Foam::scalar Foam::commonRailInjector::Cd
} }
Foam::scalar Foam::commonRailInjector::fractionOfInjection(const scalar time) const Foam::scalar Foam::commonRailInjector::fractionOfInjection
(
const scalar time
) const
{ {
return integrateTable(massFlowRateProfile_, time)/mass_; return integrateTable(massFlowRateProfile_, time)/mass_;
} }

View File

@ -103,13 +103,20 @@ private:
//- Return the fraction of the total injected liquid //- Return the fraction of the total injected liquid
scalar fractionOfInjection(const scalar time) const; scalar fractionOfInjection(const scalar time) const;
/*
//- Return the average injection velocity
scalar averageInjectionVelocityTime(const scalar liquidDensity) const;
//- Return the instantaneous injection velocity // //- Return the average injection velocity
scalar injectionVelocity(const scalar, const scalar liquidDensity) const; // scalar averageInjectionVelocityTime
*/ // (
// const scalar liquidDensity
// ) const;
// //- Return the instantaneous injection velocity
// scalar injectionVelocity
// (
// const scalar,
// const scalar liquidDensity
// ) const;
public: public:

View File

@ -465,7 +465,8 @@ void Foam::parcel::updateParcelProperties
while ((n < sDB.evaporation().nEvapIter()) && (m() > VSMALL)) while ((n < sDB.evaporation().nEvapIter()) && (m() > VSMALL))
{ {
n++; n++;
// new characteristic times does not need to be calculated the first time // new characteristic times does not need to be calculated the
// first time
if (n > 1) if (n > 1)
{ {
newDensity = fuels.rho(pg, Tnew, X()); newDensity = fuels.rho(pg, Tnew, X());

View File

@ -190,7 +190,8 @@ void Foam::parcel::setRelaxationTimes
{ {
if (!boiling) if (!boiling)
{ {
// for saturation evaporation, only use 99.99% for numerical robustness // for saturation evaporation, only use 99.99% for
// numerical robustness
scalar dm = max(SMALL, 0.9999*msat[i] - mfg[i]); scalar dm = max(SMALL, 0.9999*msat[i] - mfg[i]);
tauEvaporation[i] = sDB.evaporation().relaxationTime tauEvaporation[i] = sDB.evaporation().relaxationTime
@ -213,16 +214,23 @@ void Foam::parcel::setRelaxationTimes
scalar Nusselt = scalar Nusselt =
sDB.heatTransfer().Nu(Reynolds, Prandtl); sDB.heatTransfer().Nu(Reynolds, Prandtl);
// calculating the boiling temperature of the liquid at ambient pressure // calculating the boiling temperature of the liquid
// at ambient pressure
scalar tBoilingSurface = Td; scalar tBoilingSurface = Td;
label Niter = 0; label Niter = 0;
scalar deltaT = 10.0; scalar deltaT = 10.0;
scalar dp0 = fuels.properties()[i].pv(pressure, tBoilingSurface) - pressure; scalar dp0 =
fuels.properties()[i].pv(pressure, tBoilingSurface)
- pressure;
while ((Niter < 200) && (mag(deltaT) > 1.0e-3)) while ((Niter < 200) && (mag(deltaT) > 1.0e-3))
{ {
Niter++; Niter++;
scalar pBoil = fuels.properties()[i].pv(pressure, tBoilingSurface); scalar pBoil = fuels.properties()[i].pv
(
pressure,
tBoilingSurface
);
scalar dp = pBoil - pressure; scalar dp = pBoil - pressure;
if ( (dp > 0.0) && (dp0 > 0.0) ) if ( (dp > 0.0) && (dp0 > 0.0) )
{ {
@ -255,11 +263,19 @@ void Foam::parcel::setRelaxationTimes
forAll(sDB.gasProperties(), k) forAll(sDB.gasProperties(), k)
{ {
vapourSurfaceEnthalpy += sDB.composition().Y()[k][celli]*sDB.gasProperties()[k].H(tBoilingSurface); vapourSurfaceEnthalpy +=
vapourFarEnthalpy += sDB.composition().Y()[k][celli]*sDB.gasProperties()[k].H(temperature); sDB.composition().Y()[k][celli]
*sDB.gasProperties()[k].H(tBoilingSurface);
vapourFarEnthalpy +=
sDB.composition().Y()[k][celli]
*sDB.gasProperties()[k].H(temperature);
} }
scalar kLiquid = fuels.properties()[i].K(pressure, 0.5*(tBoilingSurface+T())); scalar kLiquid = fuels.properties()[i].K
(
pressure,
0.5*(tBoilingSurface+T())
);
tauBoiling[i] = sDB.evaporation().boilingTime tauBoiling[i] = sDB.evaporation().boilingTime
( (

View File

@ -48,7 +48,11 @@ if (( xx > collProb) && (mMin > VSMALL) && (mMax > VSMALL)) {
// use mass-averaged temperature to calculate We number // use mass-averaged temperature to calculate We number
scalar averageTemp = (pMax().T()*mMax + pMin().T()*mMin)/mTot; scalar averageTemp = (pMax().T()*mMax + pMin().T()*mMin)/mTot;
// and mass averaged mole fractions ... // and mass averaged mole fractions ...
scalarField Xav((pMax().m()*pMax().X()+pMin().m()*pMin().X())/(pMax().m() + pMin().m())); scalarField Xav
(
(pMax().m()*pMax().X()+pMin().m()*pMin().X())
/(pMax().m() + pMin().m())
);
scalar sigma = spray_.fuels().sigma(pc, averageTemp, Xav); scalar sigma = spray_.fuels().sigma(pc, averageTemp, Xav);
sigma = max(1.0e-6, sigma); sigma = max(1.0e-6, sigma);
scalar rho = spray_.fuels().rho(pc, averageTemp, Xav); scalar rho = spray_.fuels().rho(pc, averageTemp, Xav);

View File

@ -129,7 +129,9 @@ if (vAlign > 0)
pMax().d() = pMax().d() =
pow pow
( (
6.0*newMaxMass/(rhoMax*constant::mathematical::pi*nMax), 6.0
*newMaxMass
/(rhoMax*constant::mathematical::pi*nMax),
1.0/3.0 1.0/3.0
); );

View File

@ -253,7 +253,9 @@ Foam::scalar Foam::RutlandFlashBoil::boilingTime
} }
scalar Gf = scalar Gf =
4.0*alfaS*dTLB*constant::mathematical::pi*sqr(diameter/2.0)/heatOfVapour; 4.0*alfaS*dTLB
*constant::mathematical::pi*sqr(diameter/2.0)
/heatOfVapour;
// calculation of the heat transfer vapourization at superheated // calculation of the heat transfer vapourization at superheated
// conditions (temperature>tBoilingSurface) // conditions (temperature>tBoilingSurface)
@ -265,7 +267,8 @@ Foam::scalar Foam::RutlandFlashBoil::boilingTime
mag((vapourFarEnthalpy-vapourSurfaceEnthalpy)/heatOfVapour); mag((vapourFarEnthalpy-vapourSurfaceEnthalpy)/heatOfVapour);
// 2.0? or 1.0? try 1! // 2.0? or 1.0? try 1!
scalar B = 1.0*constant::mathematical::pi*kappa/cpGas*diameter*NusseltCorr; scalar B =
1.0*constant::mathematical::pi*kappa/cpGas*diameter*NusseltCorr;
scalar nPos = B*log(1.0 + A)/Gf + 1.0; scalar nPos = B*log(1.0 + A)/Gf + 1.0;
scalar nNeg = (1.0/A)*(exp(Gf/B) - 1.0 - A) + 1.0; scalar nNeg = (1.0/A)*(exp(Gf/B) - 1.0 - A) + 1.0;
@ -338,7 +341,10 @@ Foam::scalar Foam::RutlandFlashBoil::boilingTime
} }
} }
time = (constant::mathematical::pi*pow3(diameter)/6.0)*liquidDensity/(G + Gf); time =
(constant::mathematical::pi*pow3(diameter)/6.0)
*liquidDensity
/(G + Gf);
time = max(VSMALL, time); time = max(VSMALL, time);
} }

View File

@ -77,7 +77,11 @@ Foam::ChomiakInjector::ChomiakInjector
// correct velocityProfile // correct velocityProfile
forAll(sm.injectors(), i) forAll(sm.injectors(), i)
{ {
sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure); sm.injectors()[i].properties()->correctProfiles
(
sm.fuels(),
referencePressure
);
} }
} }
@ -129,7 +133,8 @@ Foam::vector Foam::ChomiakInjector::direction
scalar reduce = 0.01; scalar reduce = 0.01;
// correct beta if this is a 2D run // correct beta if this is a 2D run
// map it onto the 'angleOfWedge' // map it onto the 'angleOfWedge'
beta *= (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/constant::mathematical::pi; beta *=
(1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/constant::mathematical::pi;
beta += reduce*sm_.angleOfWedge(); beta += reduce*sm_.angleOfWedge();
normal = normal =

View File

@ -150,7 +150,10 @@ Foam::vector Foam::blobsSwirlInjector::direction
// correct beta if this is a 2D run // correct beta if this is a 2D run
// map it onto the 'angleOfWedge' // map it onto the 'angleOfWedge'
beta *= (1.0 - 2.0*reduce)*sm_.angleOfWedge()/(constant::mathematical::twoPi); beta *=
(1.0 - 2.0*reduce)
*sm_.angleOfWedge()
/(constant::mathematical::twoPi);
beta += reduce*sm_.angleOfWedge(); beta += reduce*sm_.angleOfWedge();
normal = normal =
alpha alpha

View File

@ -30,7 +30,8 @@ Description
Accurate description in: Accurate description in:
@verbatim @verbatim
Z. Han, S. Parrish, P.V. Farrell, R.D. Reitz Z. Han, S. Parrish, P.V. Farrell, R.D. Reitz
"Modeling Atomization Processes Of Pressure Swirl Hollow-Cone Fuel Sprays" "Modeling Atomization Processes Of Pressure
Swirl Hollow-Cone Fuel Sprays"
Atomization and Sprays, vol. 7, pp. 663-684, 1997 Atomization and Sprays, vol. 7, pp. 663-684, 1997
@endverbatim @endverbatim
and and

View File

@ -129,7 +129,8 @@ Foam::vector Foam::constInjector::direction
v (alpha) v (alpha)
*/ */
scalar angle = rndGen_.scalar01()*sprayAngle_[n]*constant::mathematical::pi/360.0; scalar angle =
rndGen_.scalar01()*sprayAngle_[n]*constant::mathematical::pi/360.0;
scalar alpha = sin(angle); scalar alpha = sin(angle);
scalar dcorr = cos(angle); scalar dcorr = cos(angle);
@ -143,7 +144,10 @@ Foam::vector Foam::constInjector::direction
scalar reduce = 0.01; scalar reduce = 0.01;
// correct beta if this is a 2D run // correct beta if this is a 2D run
// map it onto the 'angleOfWedge' // map it onto the 'angleOfWedge'
beta *= (1.0 - 2.0*reduce)*0.5*sm_.angleOfWedge()/constant::mathematical::pi; beta *=
(1.0 - 2.0*reduce)
*0.5*sm_.angleOfWedge()
/constant::mathematical::pi;
beta += reduce*sm_.angleOfWedge(); beta += reduce*sm_.angleOfWedge();
normal = normal =

View File

@ -172,7 +172,10 @@ Foam::vector Foam::definedHollowConeInjector::direction
// correct beta if this is a 2D run // correct beta if this is a 2D run
// map it onto the 'angleOfWedge' // map it onto the 'angleOfWedge'
beta *= (1.0 - 2.0*reduce)*sm_.angleOfWedge()/(constant::mathematical::twoPi); beta *=
(1.0 - 2.0*reduce)
*sm_.angleOfWedge()
/(constant::mathematical::twoPi);
beta += reduce*sm_.angleOfWedge(); beta += reduce*sm_.angleOfWedge();
normal = normal =
alpha alpha

View File

@ -223,7 +223,10 @@ Foam::vector Foam::definedPressureSwirlInjector::direction
// correct beta if this is a 2D run // correct beta if this is a 2D run
// map it onto the 'angleOfWedge' // map it onto the 'angleOfWedge'
beta *= (1.0 - 2.0*reduce)*sm_.angleOfWedge()/(constant::mathematical::twoPi); beta *=
(1.0 - 2.0*reduce)
*sm_.angleOfWedge()
/(constant::mathematical::twoPi);
beta += reduce*sm_.angleOfWedge(); beta += reduce*sm_.angleOfWedge();
normal = normal =
alpha alpha
@ -261,7 +264,10 @@ Foam::scalar Foam::definedPressureSwirlInjector::velocity
} }
Foam::scalar Foam::definedPressureSwirlInjector::averageVelocity(const label i) const Foam::scalar Foam::definedPressureSwirlInjector::averageVelocity
(
const label i
) const
{ {
const injectorType& it = sm_.injectors()[i].properties(); const injectorType& it = sm_.injectors()[i].properties();

View File

@ -139,7 +139,10 @@ Foam::vector Foam::hollowConeInjector::direction
// correct beta if this is a 2D run // correct beta if this is a 2D run
// map it onto the 'angleOfWedge' // map it onto the 'angleOfWedge'
beta *= (1.0 - 2.0*reduce)*sm_.angleOfWedge()/(constant::mathematical::twoPi); beta *=
(1.0 - 2.0*reduce)
*sm_.angleOfWedge()
/(constant::mathematical::twoPi);
beta += reduce*sm_.angleOfWedge(); beta += reduce*sm_.angleOfWedge();
normal = normal =
alpha alpha

View File

@ -145,7 +145,10 @@ Foam::vector Foam::pressureSwirlInjector::direction
// correct beta if this is a 2D run // correct beta if this is a 2D run
// map it onto the 'angleOfWedge' // map it onto the 'angleOfWedge'
beta *= (1.0 - 2.0*reduce)*sm_.angleOfWedge()/(constant::mathematical::twoPi); beta *=
(1.0 - 2.0*reduce)
*sm_.angleOfWedge()
/(constant::mathematical::twoPi);
beta += reduce*sm_.angleOfWedge(); beta += reduce*sm_.angleOfWedge();
normal = normal =
alpha alpha

View File

@ -92,7 +92,8 @@ Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::energyRatio
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template <class CloudType> template <class CloudType>
Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::LarsenBorgnakkeVariableHardSphere Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::
LarsenBorgnakkeVariableHardSphere
( (
const dictionary& dict, const dictionary& dict,
CloudType& cloud CloudType& cloud

View File

@ -76,7 +76,8 @@ const Foam::dictionary& Foam::DevolatilisationModel<CloudType>::dict() const
template<class CloudType> template<class CloudType>
const Foam::dictionary& Foam::DevolatilisationModel<CloudType>::coeffDict() const const Foam::dictionary&
Foam::DevolatilisationModel<CloudType>::coeffDict() const
{ {
return coeffDict_; return coeffDict_;
} }
@ -87,4 +88,3 @@ const Foam::dictionary& Foam::DevolatilisationModel<CloudType>::coeffDict() cons
#include "DevolatilisationModelNew.C" #include "DevolatilisationModelNew.C"
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,7 +29,11 @@ License
namespace Foam namespace Foam
{ {
defineTemplateTypeNameAndDebug(IOList<reactingMultiphaseParcelInjectionData>, 0); defineTemplateTypeNameAndDebug
(
IOList<reactingMultiphaseParcelInjectionData>,
0
);
} }

View File

@ -132,7 +132,10 @@ public:
} }
//- Read energyScalingFunction dictionary //- Read energyScalingFunction dictionary
virtual bool read(const dictionary& energyScalingFunctionProperties) = 0; virtual bool read
(
const dictionary& energyScalingFunctionProperties
) = 0;
}; };

View File

@ -31,7 +31,8 @@ Description
@verbatim @verbatim
@ARTICLE{MA_Maitland_Smith, @ARTICLE{MA_Maitland_Smith,
author = {{Maitland}, G.~C. and {Smith}, E.~B.}, author = {{Maitland}, G.~C. and {Smith}, E.~B.},
title = {A simplified representation of intermolecular potential energy}, title = {A simplified representation of
intermolecular potential energy},
journal = {Chemical Physics Letters}, journal = {Chemical Physics Letters},
year = 1973, year = 1973,
month = oct, month = oct,
@ -45,7 +46,8 @@ Description
Parameters for other monoatomics from: Parameters for other monoatomics from:
@verbatim @verbatim
@BOOK{MD_Maitland_Rigby_Smith_Wakeham, @BOOK{MD_Maitland_Rigby_Smith_Wakeham,
AUTHOR = {Geoffrey C. Maitland and Maurice Rigby and E. Brian Smith and William A. Wakeham}, AUTHOR = {Geoffrey C. Maitland and Maurice Rigby and
E. Brian Smith and William A. Wakeham},
TITLE = {Intermolecular Forces: Their Origin and Determination}, TITLE = {Intermolecular Forces: Their Origin and Determination},
PUBLISHER = {Oxford University Press}, PUBLISHER = {Oxford University Press},
YEAR = {1981} YEAR = {1981}

View File

@ -50,7 +50,8 @@ void Foam::tetherPotentialList::readTetherPotentialDict
if (tetherId == -1) if (tetherId == -1)
{ {
FatalErrorIn("tetherPotentialList::readTetherPotentialDict") FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
<< nl << "No matching entry found in siteIdList for tether name " << nl
<< "No matching entry found in siteIdList for tether name "
<< tetherPotentialName << tetherPotentialName
<< abort(FatalError); << abort(FatalError);
} }

View File

@ -590,7 +590,10 @@ Foam::booleanSurface::booleanSurface
// Copy points from subSurf1 and remember the labels of the ones in // Copy points from subSurf1 and remember the labels of the ones in
// the intersection // the intersection
labelList intersectionLabels(cutSurf1.nPoints() - cutSurf1.nSurfacePoints()); labelList intersectionLabels
(
cutSurf1.nPoints() - cutSurf1.nSurfacePoints()
);
label combinedPointI = 0; label combinedPointI = 0;

View File

@ -250,11 +250,11 @@ void d2vec_part_quick_a ( int n, double a[], int *l, int *r )
return; return;
} }
//******************************************************************************* //******************************************************************************
void d2vec_permute ( int n, double a[], int p[] ) void d2vec_permute ( int n, double a[], int p[] )
//******************************************************************************* //******************************************************************************
// //
// Purpose: // Purpose:
// //
@ -383,7 +383,8 @@ int *d2vec_sort_heap_index_a ( int n, double a[] )
// //
// Purpose: // Purpose:
// //
// D2VEC_SORT_HEAP_INDEX_A does an indexed heap ascending sort of an R2 vector. // D2VEC_SORT_HEAP_INDEX_A does an indexed heap ascending sort of
// an R2 vector.
// //
// Discussion: // Discussion:
// //
@ -864,7 +865,8 @@ void dmat_uniform ( int m, int n, double b, double c, int *seed, double r[] )
// //
// Purpose: // Purpose:
// //
// DMAT_UNIFORM fills a double precision array with scaled pseudorandom values. // DMAT_UNIFORM fills a double precision array with scaled
// pseudorandom values.
// //
// Discussion: // Discussion:
// //
@ -983,8 +985,9 @@ int dtris2 ( int point_num, double point_xy[], int *tri_num,
// //
// Input, int POINT_NUM, the number of vertices. // Input, int POINT_NUM, the number of vertices.
// //
// Input/output, double POINT_XY[POINT_NUM*2], the coordinates of the vertices. // Input/output, double POINT_XY[POINT_NUM*2], the coordinates of
// On output, the vertices have been sorted into dictionary order. // the vertices. On output, the vertices have been sorted into
// dictionary order.
// //
// Output, int *TRI_NUM, the number of triangles in the triangulation; // Output, int *TRI_NUM, the number of triangles in the triangulation;
// TRI_NUM is equal to 2*POINT_NUM - NB - 2, where NB is the number // TRI_NUM is equal to 2*POINT_NUM - NB - 2, where NB is the number
@ -1703,11 +1706,11 @@ int i_sign ( int i )
} }
} }
//******************************************************************************* //******************************************************************************
int i_wrap ( int ival, int ilo, int ihi ) int i_wrap ( int ival, int ilo, int ihi )
//******************************************************************************* //******************************************************************************
// //
// Purpose: // Purpose:
// //
@ -3008,7 +3011,8 @@ double *triangle_circumcenter_2d ( double t[] )
// //
// Input, double T[2*3], the triangle vertices. // Input, double T[2*3], the triangle vertices.
// //
// Output, double *X, *Y, the coordinates of the circumcenter of the triangle. // Output, double *X, *Y, the coordinates of the circumcenter of
// the triangle.
// //
{ {
# define DIM_NUM 2 # define DIM_NUM 2
@ -3043,8 +3047,8 @@ double *triangle_circumcenter_2d ( double t[] )
} }
//****************************************************************************** //******************************************************************************
bool triangulation_plot_eps ( const char *file_out_name, int g_num, double g_xy[], bool triangulation_plot_eps ( const char *file_out_name, int g_num,
int tri_num, int nod_tri[] ) double g_xy[], int tri_num, int nod_tri[] )
//****************************************************************************** //******************************************************************************
// //

View File

@ -30,8 +30,8 @@ void ivec_heap_d ( int n, int a[] );
int *ivec_indicator ( int n ); int *ivec_indicator ( int n );
void ivec_sort_heap_a ( int n, int a[] ); void ivec_sort_heap_a ( int n, int a[] );
void ivec_sorted_unique ( int n, int a[], int *nuniq ); void ivec_sorted_unique ( int n, int a[], int *nuniq );
int lrline ( double xu, double yu, double xv1, double yv1, double xv2, double yv2, int lrline ( double xu, double yu, double xv1, double yv1, double xv2,
double dv ); double yv2, double dv );
bool perm_check ( int n, int p[] ); bool perm_check ( int n, int p[] );
void perm_inv ( int n, int p[] ); void perm_inv ( int n, int p[] );
int *points_delaunay_naive_2d ( int n, double p[], int *ntri ); int *points_delaunay_naive_2d ( int n, double p[], int *ntri );
@ -42,10 +42,9 @@ int swapec ( int i, int *top, int *btri, int *bedg, int point_num,
void timestamp ( void ); void timestamp ( void );
char *timestring ( void ); char *timestring ( void );
double *triangle_circumcenter_2d ( double t[] ); double *triangle_circumcenter_2d ( double t[] );
bool triangulation_plot_eps ( const char *file_out_name, int g_num, double g_xy[], bool triangulation_plot_eps ( const char *file_out_name,
int tri_num, int nod_tri[] ); int g_num, double g_xy[], int tri_num, int nod_tri[] );
void triangulation_print ( int point_num, double xc[], int tri_num, void triangulation_print ( int point_num, double xc[], int tri_num,
int tri_vert[], int tri_nabe[] ); int tri_vert[], int tri_nabe[] );
void vbedg ( double x, double y, int point_num, double point_xy[], int tri_num, void vbedg ( double x, double y, int point_num, double point_xy[], int tri_num,
int tri_vert[], int tri_nabe[], int *ltri, int *ledg, int *rtri, int *redg ); int tri_vert[], int tri_nabe[], int *ltri, int *ledg, int *rtri, int *redg );

View File

@ -29,7 +29,11 @@ License
namespace Foam namespace Foam
{ {
defineNamedTemplateTypeNameAndDebug(surfaceInterpolateFieldsFunctionObject, 0); defineNamedTemplateTypeNameAndDebug
(
surfaceInterpolateFieldsFunctionObject,
0
);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (

View File

@ -25,8 +25,8 @@ Typedef
Foam::surfaceInterpolateFieldsFunctionObject Foam::surfaceInterpolateFieldsFunctionObject
Description Description
FunctionObject wrapper around surfaceInterpolateFields to allow them to be created via FunctionObject wrapper around surfaceInterpolateFields to allow
the functions entry within controlDict. them to be created via the functions entry within controlDict.
SourceFiles SourceFiles
surfaceInterpolateFieldsFunctionObject.C surfaceInterpolateFieldsFunctionObject.C

View File

@ -258,7 +258,8 @@ Foam::tmp<Foam::volScalarField> Foam::interpolatedSolidThermo::Hf() const
} }
Foam::tmp<Foam::volScalarField> Foam::interpolatedSolidThermo::emissivity() const Foam::tmp<Foam::volScalarField>
Foam::interpolatedSolidThermo::emissivity() const
{ {
tmp<volScalarField> temissivity tmp<volScalarField> temissivity
( (

View File

@ -28,7 +28,9 @@ Description
Rosin-Rammler pdf Rosin-Rammler pdf
@f[ @f[
cumulative pdf = (1.0 - exp( -((x - d0)/d)^n ) / (1.0 - exp( -((d1 - d0)/d)^n ) cumulative pdf =
(1.0 - exp( -(( x - d0)/d)^n )
/ (1.0 - exp( -((d1 - d0)/d)^n )
@f] @f]

View File

@ -379,8 +379,11 @@ void LRR::correct()
forAll(curPatch, facei) forAll(curPatch, facei)
{ {
label faceCelli = curPatch.faceCells()[facei]; label faceCelli = curPatch.faceCells()[facei];
P[faceCelli] P[faceCelli] *= min
*= min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 100.0); (
G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL),
100.0
);
} }
} }
} }

View File

@ -417,8 +417,11 @@ void LaunderGibsonRSTM::correct()
forAll(curPatch, facei) forAll(curPatch, facei)
{ {
label faceCelli = curPatch.faceCells()[facei]; label faceCelli = curPatch.faceCells()[facei];
P[faceCelli] *= P[faceCelli] *= min
min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 100.0); (
G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL),
100.0
);
} }
} }
} }

View File

@ -340,8 +340,11 @@ void LRR::correct()
forAll(curPatch, facei) forAll(curPatch, facei)
{ {
label faceCelli = curPatch.faceCells()[facei]; label faceCelli = curPatch.faceCells()[facei];
P[faceCelli] P[faceCelli] *= min
*= min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 1.0); (
G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL),
1.0
);
} }
} }
} }

View File

@ -14,7 +14,8 @@
phi = phiU + phi = phiU +
( (
fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() fvc::interpolate(interface.sigmaK())
*fvc::snGrad(alpha1)*mesh.magSf()
+ fvc::interpolate(rho)*(g & mesh.Sf()) + fvc::interpolate(rho)*(g & mesh.Sf())
)*rUAf; )*rUAf;
adjustPhi(phi, U, p); adjustPhi(phi, U, p);