1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
//======================================================================
// Setting filenames
//======================================================================
int USERD_set_filenames
(
char filename_1[],
char filename_2[],
char the_path[],
int swapbytes
)
{
#ifdef ENSIGHTDEBUG
Info<< "Entering: USERD_set_filenames" << endl << flush;
#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] == '/')
{
the_path[lRoot-1] = char(NULL);
}
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;
if (!isDir(rootDir/caseDir))
{
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
timeDirs = Foam::Time::findTimes(rootDir/caseDir);
Num_time_steps = timeDirs.size() - 1;
nPatches = meshPtr->boundaryMesh().size();
// set the number of fields and store their names
// a valid field must exist for all time-steps
runTime.setTime(timeDirs.last(), timeDirs.size()-1);
IOobjectList objects(*meshPtr, runTime.timeName());
fieldNames = objects.names();
// 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);
forAll(fieldNames, n)
{
bool isitScalar = false;
forAll(scalars,i)
{
if (fieldNames[n] == scalars[i])
{
isitScalar = true;
var2field[nVar++] = n;
}
}
isScalar[n] = isitScalar;
}
wordList vectors = objects.names(vectorName);
forAll(fieldNames, n)
{
bool isitVector = false;
forAll(vectors,i)
{
if (fieldNames[n] == vectors[i])
{
isitVector = true;
var2field[nVar++] = n;
}
}
isVector[n] = isitVector;
}
wordList tensors = objects.names(tensorName);
forAll(fieldNames, n)
{
bool isitTensor = false;
forAll(tensors,i)
{
if (fieldNames[n] == tensors[i])
{
isitTensor = true;
var2field[nVar++] = n;
}
}
isTensor[n] = isitTensor;
}
bool lagrangianNamesFound = false;
label n = 0;
while (!lagrangianNamesFound && n < Num_time_steps)
{
runTime.setTime(timeDirs[n+1], n+1);
Cloud<passiveParticle> lagrangian(*meshPtr);
n++;
if (lagrangian.size())
{
lagrangianNamesFound = true;
}
}
IOobject sprayHeader
(
"positions",
runTime.timeName(),
cloud::prefix,
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (sprayHeader.headerOk())
{
Info<< "[Found lagrangian]" << endl;
delete sprayPtr;
sprayPtr = new Cloud<passiveParticle>(*meshPtr);
IOobjectList objects(*meshPtr, runTime.timeName(), cloud::prefix);
lagrangianScalarNames =
objects.names(sprayScalarFieldName);
lagrangianVectorNames =
objects.names(sprayVectorFieldName);
isSpray[fieldNames.size()] = true;
nSprayVariables += lagrangianScalarNames.size();
nSprayVariables += lagrangianVectorNames.size();
Num_unstructured_parts++;
}
Current_time_step = Num_time_steps;
runTime.setTime(timeDirs[Current_time_step], Current_time_step);
Num_variables = nVar + nSprayVariables;
Numparts_available =
Num_unstructured_parts + Num_structured_parts + nPatches;
#ifdef ENSIGHTDEBUG
Info<< "Leaving: USERD_set_filenames" << endl << flush;
#endif
return Z_OK;
}
|