modified rBaseMirror to read fields from dataBase directory

This commit is contained in:
asanaz
2018-04-25 14:14:54 +02:00
parent b7bc6cd1b7
commit beadd7fe18
7 changed files with 66 additions and 48 deletions

View File

@ -33,5 +33,7 @@ refDirection (1 0 0);
fieldName U;
dataBaseName dataBase;
// ************************************************************************* //

View File

@ -14,16 +14,4 @@
vector refDirection(mirrorProperties.lookup("refDirection"));
word fieldName(mirrorProperties.lookup("fieldName"));
volScalarField origField
(
IOobject
(
fieldName,
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh
);
word dataBaseName(mirrorProperties.lookup("dataBaseName"));

View File

@ -55,15 +55,19 @@ int main(int argc, char *argv[])
Info << "end time = " << runTime.endTime() << endl;
// check which time directories are present
instantList timeDirs = timeSelector::select0(runTime, args);
runTime.setTime(timeDirs[0], 0);
// instantList timeDirs = timeSelector::select0(runTime, args);
// runTime.setTime(timeDirs[0], 0);
#include "createMesh.H"
#include "createFields.H"
Foam::Time recTime(fileName(dataBaseName), "", "../system", "../constant", false);
instantList timeDirs(recTime.times());
recTime.setTime(timeDirs[0],0);
#include "readFields.H"
Info << fieldName << endl;
volScalarField transformedField = origField;
@ -76,26 +80,29 @@ int main(int argc, char *argv[])
label shift = 0;
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
t = runTime.value();
if (recTime.timeName() == "constant") continue;
recTime.setTime(timeDirs[timeI], timeI);
t = recTime.value();
if(t < startTime) continue;
if(t > endTime) continue;
shift++;
}
scalar dt = origTimeRange / (shift - 1.0);
runTime.setEndTime(startTime + 2 * origTimeRange + dt);
recTime.setEndTime(startTime + 2 * origTimeRange + dt);
label cellI_transformed = -1;
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
t = runTime.value();
recTime.setTime(timeDirs[timeI], timeI);
t = recTime.value();
if(t < startTime) continue;
if(t > endTime) continue;
Info << "time = " << t << ", time index = " << timeI << endl;
#include "createFields.H"
#include "readFields.H"
forAll(transformedField, cellI)
{
@ -115,7 +122,7 @@ int main(int argc, char *argv[])
}
shiftedTimeI = timeI + shift;
t = runTime.value() + origTimeRange + dt;
t = recTime.value() + origTimeRange + dt;
runTime.setTime(t, shiftedTimeI);
Info << "creating transformed fields for time = " << t << ", time index = " << shiftedTimeI << endl;
transformedField.write();

View File

@ -0,0 +1,13 @@
volScalarField origField
(
IOobject
(
fieldName,
recTime.timePath(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);

View File

@ -14,16 +14,4 @@
vector refDirection(mirrorProperties.lookup("refDirection"));
word fieldName(mirrorProperties.lookup("fieldName"));
volVectorField origField
(
IOobject
(
fieldName,
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh
);
word dataBaseName(mirrorProperties.lookup("dataBaseName"));

View File

@ -54,15 +54,19 @@ int main(int argc, char *argv[])
Info << "end time = " << runTime.endTime() << endl;
// check which time directories are present
instantList timeDirs = timeSelector::select0(runTime, args);
runTime.setTime(timeDirs[0], 0);
//instantList timeDirs = timeSelector::select0(runTime, args);
//runTime.setTime(timeDirs[0], 0);
#include "createMesh.H"
#include "createFields.H"
Foam::Time recTime(fileName(dataBaseName), "", "../system", "../constant", false);
instantList timeDirs(recTime.times());
recTime.setTime(timeDirs[0],0);
#include "readFields.H"
Info << fieldName << endl;
volVectorField transformedField = origField;
@ -75,26 +79,28 @@ int main(int argc, char *argv[])
label shift = 0;
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
t = runTime.value();
if (recTime.timeName() == "constant") continue;
recTime.setTime(timeDirs[timeI], timeI);
t = recTime.value();
if(t < startTime) continue;
if(t > endTime) continue;
shift++;
}
scalar dt = origTimeRange / (shift - 1.0);
runTime.setEndTime(startTime + 2 * origTimeRange + dt);
recTime.setEndTime(startTime + 2 * origTimeRange + dt);
label cellI_transformed = -1;
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
t = runTime.value();
recTime.setTime(timeDirs[timeI], timeI);
t = recTime.value();
if(t < startTime) continue;
if(t > endTime) continue;
Info << "time = " << t << ", time index = " << timeI << endl;
#include "createFields.H"
#include "readFields.H"
forAll(transformedField, cellI)
{
@ -114,7 +120,7 @@ int main(int argc, char *argv[])
}
shiftedTimeI = timeI + shift;
t = runTime.value() + origTimeRange + dt;
t = recTime.value() + origTimeRange + dt;
runTime.setTime(t, shiftedTimeI);
Info << "creating transformed fields for time = " << t << ", time index = " << shiftedTimeI << endl;
transformedField.write();

View File

@ -0,0 +1,14 @@
volVectorField origField
(
IOobject
(
fieldName,
recTime.timePath(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);