2010-05-12 13:27:55 +00:00
|
|
|
//======================================================================
|
|
|
|
// Setting filenames
|
|
|
|
//======================================================================
|
|
|
|
int USERD_set_filenames
|
|
|
|
(
|
|
|
|
char filename_1[],
|
|
|
|
char filename_2[],
|
|
|
|
char the_path[],
|
|
|
|
int swapbytes
|
|
|
|
)
|
|
|
|
{
|
|
|
|
#ifdef ENSIGHTDEBUG
|
2019-01-25 16:22:44 +00:00
|
|
|
Info<< "Entering: USERD_set_filenames" << endl << flush;
|
2010-05-12 13:27:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
char tmp[100];
|
|
|
|
|
|
|
|
label lRoot = strlen(the_path);
|
|
|
|
label lCase = strlen(filename_1);
|
|
|
|
|
|
|
|
bool cleared = false;
|
|
|
|
|
|
|
|
while (!cleared)
|
|
|
|
{
|
|
|
|
lRoot = strlen(the_path);
|
|
|
|
lCase = strlen(filename_1);
|
|
|
|
|
|
|
|
// remove the last '/' from rootDir
|
|
|
|
if (the_path[lRoot-1] == '/')
|
|
|
|
{
|
2019-01-25 16:22:44 +00:00
|
|
|
the_path[lRoot-1] = '\0';
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cleared = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rootDir = the_path;
|
|
|
|
|
|
|
|
// the path is pre-pended to filename_1
|
|
|
|
// 1 is the 'Geometry' : 2 the 'Result' which is null here
|
|
|
|
// since two_field is FALSE
|
|
|
|
for (label i=0; i<lCase-lRoot;i++)
|
|
|
|
{
|
|
|
|
tmp[i] = filename_1[i+1+lRoot];
|
|
|
|
}
|
|
|
|
caseDir = tmp;
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
if (!isDir(rootDir/caseDir))
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
Info<< rootDir/caseDir << " is not a valid directory."
|
|
|
|
<< endl;
|
|
|
|
return Z_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
// construct the global pointers to the database and mesh
|
|
|
|
|
|
|
|
delete meshPtr;
|
|
|
|
delete runTimePtr;
|
|
|
|
|
|
|
|
runTimePtr = new Time
|
|
|
|
(
|
|
|
|
Time::controlDictName,
|
|
|
|
rootDir,
|
|
|
|
caseDir
|
|
|
|
);
|
|
|
|
|
|
|
|
Time& runTime = *runTimePtr;
|
|
|
|
|
|
|
|
meshPtr = new fvMesh
|
|
|
|
(
|
|
|
|
IOobject
|
|
|
|
(
|
|
|
|
fvMesh::defaultRegion,
|
|
|
|
runTime.timeName(),
|
|
|
|
runTime
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// set the available number of time-steps
|
2010-08-26 14:22:03 +00:00
|
|
|
timeDirs = Foam::Time::findTimes(rootDir/caseDir);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
Num_time_steps = timeDirs.size() - 1;
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
nPatches = meshPtr->boundaryMesh().size();
|
|
|
|
|
|
|
|
// set the number of fields and store their names
|
|
|
|
// a valid field must exist for all time-steps
|
2010-08-26 14:22:03 +00:00
|
|
|
runTime.setTime(timeDirs[timeDirs.size()-1], timeDirs.size()-1);
|
2010-05-12 13:27:55 +00:00
|
|
|
IOobjectList objects(*meshPtr, runTime.timeName());
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
fieldNames = objects.names();
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
// because of the spray being a 'field' ...
|
|
|
|
// get the availabe number of variables and
|
|
|
|
// check for type (scalar/vector/tensor)
|
|
|
|
|
|
|
|
label nVar = 0;
|
|
|
|
wordList scalars = objects.names(scalarName);
|
|
|
|
|
2019-01-25 16:22:44 +00:00
|
|
|
forAll (fieldNames, n)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
bool isitScalar = false;
|
|
|
|
forAll(scalars,i)
|
|
|
|
{
|
|
|
|
if (fieldNames[n] == scalars[i])
|
|
|
|
{
|
|
|
|
isitScalar = true;
|
|
|
|
var2field[nVar++] = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isScalar[n] = isitScalar;
|
|
|
|
}
|
|
|
|
|
|
|
|
wordList vectors = objects.names(vectorName);
|
|
|
|
|
2019-01-25 16:22:44 +00:00
|
|
|
forAll (fieldNames, n)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
bool isitVector = false;
|
|
|
|
forAll(vectors,i)
|
|
|
|
{
|
|
|
|
if (fieldNames[n] == vectors[i])
|
|
|
|
{
|
|
|
|
isitVector = true;
|
|
|
|
var2field[nVar++] = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isVector[n] = isitVector;
|
|
|
|
}
|
|
|
|
|
|
|
|
wordList tensors = objects.names(tensorName);
|
|
|
|
|
2019-01-25 16:22:44 +00:00
|
|
|
forAll (fieldNames, n)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
bool isitTensor = false;
|
|
|
|
forAll(tensors,i)
|
|
|
|
{
|
|
|
|
if (fieldNames[n] == tensors[i])
|
|
|
|
{
|
|
|
|
isitTensor = true;
|
|
|
|
var2field[nVar++] = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isTensor[n] = isitTensor;
|
|
|
|
}
|
2010-08-26 14:22:03 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
bool lagrangianNamesFound = false;
|
|
|
|
label n = 0;
|
2010-08-26 14:22:03 +00:00
|
|
|
while (!lagrangianNamesFound && n < Num_time_steps)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-08-26 14:22:03 +00:00
|
|
|
runTime.setTime(timeDirs[n+1], n+1);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2019-01-25 16:22:44 +00:00
|
|
|
Cloud<passiveParticle> lagrangian(*meshPtr, cloud::defaultName);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
n++;
|
2019-01-25 16:22:44 +00:00
|
|
|
if (lagrangian.size() > 0)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
lagrangianNamesFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IOobject sprayHeader
|
|
|
|
(
|
|
|
|
"positions",
|
|
|
|
runTime.timeName(),
|
2010-08-26 14:22:03 +00:00
|
|
|
cloud::prefix,
|
2010-05-12 13:27:55 +00:00
|
|
|
runTime,
|
|
|
|
IOobject::NO_READ,
|
|
|
|
IOobject::NO_WRITE,
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
2019-01-25 16:22:44 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
if (sprayHeader.headerOk())
|
|
|
|
{
|
|
|
|
Info << "[Found lagrangian]" << endl;
|
|
|
|
|
|
|
|
delete sprayPtr;
|
2010-08-26 14:22:03 +00:00
|
|
|
|
2019-01-25 16:22:44 +00:00
|
|
|
sprayPtr = new Cloud<passiveParticle>(*meshPtr, cloud::defaultName);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
IOobjectList objects(*meshPtr, runTime.timeName(), cloud::prefix);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2019-01-25 16:22:44 +00:00
|
|
|
lagrangianScalarNames = objects.names(sprayScalarFieldName);
|
|
|
|
lagrangianVectorNames = objects.names(sprayVectorFieldName);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
isSpray[fieldNames.size()] = true;
|
|
|
|
|
|
|
|
nSprayVariables += lagrangianScalarNames.size();
|
|
|
|
nSprayVariables += lagrangianVectorNames.size();
|
|
|
|
|
|
|
|
Num_unstructured_parts++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Current_time_step = Num_time_steps;
|
2010-08-26 14:22:03 +00:00
|
|
|
runTime.setTime(timeDirs[Current_time_step], Current_time_step);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
Num_variables = nVar + nSprayVariables;
|
|
|
|
Numparts_available = Num_unstructured_parts + Num_structured_parts + nPatches;
|
|
|
|
|
|
|
|
#ifdef ENSIGHTDEBUG
|
2019-01-25 16:22:44 +00:00
|
|
|
Info<< "Leaving: USERD_set_filenames" << endl << flush;
|
2010-05-12 13:27:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return Z_OK;
|
|
|
|
}
|