CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Give the file the proper header for being used as TimeVaryingMappedFixedValue input

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 2 Post By syavash
  • 1 Post By Likun

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 9, 2015, 19:01
Default Give the file the proper header for being used as TimeVaryingMappedFixedValue input
  #1
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Hi Foamers,

In the file foamFileSurfaceWriter.C in "src/sampling/sampledSurface/writers/foamFile" , I can see the following line

Code:
   // values
    OFstream(valuesDir/fieldName)()  << values;
which prints the sampled field, e.g. U as the output. I should sample velocity at the inlet BC at each time step, during a very long time. In this way, I would have a huge number of time folders, yet lacking the OpenFOAM header (just vector values and coordinates).

I want to feed these time series into another simulation as boundary condition using TimeVaryingMappedFixedValue BC. But this BC demands for input files with headers.

Unfortunately, it is not possible to add header to each file manually, because the number is huge!
I have tried something like the following code to add the proper header, but without success:

Code:
vectorAverageField values
    (
    IOobject
          (
        "values",
        runTime.constant()/valuesDir/fieldName,
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
          )
       ,facesSet.size()
        );
        
        values.write()
the following error appears when compiling:

Code:
SOURCE=sampledSurface/writers/foamFile/foamFileSurfaceWriter.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/finiteVolume/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/meshTools/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/surfMesh/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/fileFormats/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/triSurface/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/conversion/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/lagrangian/basic/lnInclude -IlnInclude -I. -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/OpenFOAM/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/foamFileSurfaceWriter.o
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C: In member function ‘void Foam::foamFileSurfaceWriter::writeTemplate(const Foam::fileName&, const Foam::fileName&, const pointField&, const faceList&, const Foam::word&, const Foam::Field<Type>&, bool, bool) const’:
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:82:6: error: ‘vectorAverageField’ was not declared in this scope
      vectorAverageField values
      ^
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:82:25: error: expected ‘;’ before ‘values’
      vectorAverageField values
                         ^
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:96:1: error: expected ‘;’ before ‘}’ token
 }
 ^
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C: In instantiation of ‘void Foam::foamFileSurfaceWriter::writeTemplate(const Foam::fileName&, const Foam::fileName&, const pointField&, const faceList&, const Foam::word&, const Foam::Field<Type>&, bool, bool) const [with Type = double; Foam::pointField = Foam::Field<Foam::Vector<double> >; Foam::faceList = Foam::List<Foam::face>]’:
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:157:1:   required from here
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:95:9: error: ‘const class Foam::Field<double>’ has no member named ‘write’
         values.write()
         ^
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C: In instantiation of ‘void Foam::foamFileSurfaceWriter::writeTemplate(const Foam::fileName&, const Foam::fileName&, const pointField&, const faceList&, const Foam::word&, const Foam::Field<Type>&, bool, bool) const [with Type = Foam::Vector<double>; Foam::pointField = Foam::Field<Foam::Vector<double> >; Foam::faceList = Foam::List<Foam::face>]’:
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:157:1:   required from here
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:95:9: error: ‘const class Foam::Field<Foam::Vector<double> >’ has no member named ‘write’
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C: In instantiation of ‘void Foam::foamFileSurfaceWriter::writeTemplate(const Foam::fileName&, const Foam::fileName&, const pointField&, const faceList&, const Foam::word&, const Foam::Field<Type>&, bool, bool) const [with Type = Foam::SphericalTensor<double>; Foam::pointField = Foam::Field<Foam::Vector<double> >; Foam::faceList = Foam::List<Foam::face>]’:
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:157:1:   required from here
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:95:9: error: ‘const class Foam::Field<Foam::SphericalTensor<double> >’ has no member named ‘write’
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C: In instantiation of ‘void Foam::foamFileSurfaceWriter::writeTemplate(const Foam::fileName&, const Foam::fileName&, const pointField&, const faceList&, const Foam::word&, const Foam::Field<Type>&, bool, bool) const [with Type = Foam::SymmTensor<double>; Foam::pointField = Foam::Field<Foam::Vector<double> >; Foam::faceList = Foam::List<Foam::face>]’:
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:157:1:   required from here
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:95:9: error: ‘const class Foam::Field<Foam::SymmTensor<double> >’ has no member named ‘write’
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C: In instantiation of ‘void Foam::foamFileSurfaceWriter::writeTemplate(const Foam::fileName&, const Foam::fileName&, const pointField&, const faceList&, const Foam::word&, const Foam::Field<Type>&, bool, bool) const [with Type = Foam::Tensor<double>; Foam::pointField = Foam::Field<Foam::Vector<double> >; Foam::faceList = Foam::List<Foam::face>]’:
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:157:1:   required from here
sampledSurface/writers/foamFile/foamFileSurfaceWriter.C:95:9: error: ‘const class Foam::Field<Foam::Tensor<double> >’ has no member named ‘write’
make: *** [Make/linux64GccDPOpt/foamFileSurfaceWriter.o] Error 1
Is there any way to solve this problem and adding the proper header to the files generated through the sampling??

Thanks,
Syavash
uckmhnds and HeleShawman like this.
syavash is offline   Reply With Quote

Old   October 12, 2015, 07:43
Default
  #2
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Anyone who might be interested?? This is a real problem for me since I need inlet velocity at each time step to be saved and used as boundary condition for another LES simulation!
I also checked sample utility but it similarly only saves values and generates no header!

TimeVaryingMappedFixedValue demands a header for velocity like this:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       vectorAverageField;
    object      values;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
How can I generate a header like one in above for my sampled inlet boundary??

Thanks,
Syavash
syavash is offline   Reply With Quote

Old   October 12, 2015, 07:46
Default
  #3
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Anyone who might be interested?? This is a real problem for me since I need inlet velocity at each time step to be saved and used as boundary condition for another LES simulation!
I also checked sample utility but it similarly only saves values and generates no header!

TimeVaryingMappedFixedValue demands a header for velocity like this:

[CODE]

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       vectorAverageField;
    object      values;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
How can I generate a header like one in above for my sampled inlet boundary??

Thanks,
Syavash
syavash is offline   Reply With Quote

Old   October 13, 2015, 07:28
Default
  #4
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
No one can help me??!
I am really stuck in this!
syavash is offline   Reply With Quote

Old   October 15, 2015, 04:23
Default
  #5
Member
 
Likun
Join Date: Feb 2013
Posts: 52
Rep Power: 13
Likun is on a distinguished road
Send a message via Skype™ to Likun
Dear Syavash,

I also met similar problem before, and I have written a matlab script to add the head to the sampled file.

Suppose your sampleDict reads like this:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      sampleDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

//Example to output facecentres, faces and points for the selected patches

interpolationScheme cellPoint;

surfaceFormat foamFile;

surfaces
(
        mySampleSurface
        {
                type           plane;
                basePoint      (0.01 0.0 0.0);
                normalVector   (1.0 0.0 0.0);
//      type      patch;
//      patches  (OUTLET);
        }
);

//Not really required when run before a simulation as the velocity will be empty.
fields          ( U );

// ************************************************************************* //
After sample you will have many timestep folders under the directory: 'xx/postProcessing/surfaces/' and within each timestep folder you have the sampled surface 'mySampleSurface/'.

Here is the matlab script that I used to add the header and to move the required files directly under the timestep folder.

Code:
num_time = 9; % Total number of timestep folders

stp_time = 1e-4;         % size of timestep

case_dir = 'xx/postProcessing/surfaces/';


for i = 1:num_time

    time_dir = (i-1)*stp_time;  
                  
    old_dir = strcat(case_dir, num2str(time_dir), '/mySampleSurface/vectorField/');
    
    new_dir = strcat(case_dir, num2str(time_dir), '/');
    
    fid = fopen([new_dir 'header'],'w');
    
    fprintf(fid,'/*--------------------------------*- C++ -*----------------------------------*\\');
    fprintf(fid,'\n| =========                 |                                                 |');
    fprintf(fid,'\n| \\      /  F ield          | OpenFOAM: The Open Source CFD Toolbox           |');
    fprintf(fid,'\n|  \\    /   O peration      | Version:  2.3.x                                 |');
    fprintf(fid,'\n|   \\  /    A nd            | Web:      http://www.OpenFOAM.com               |');
    fprintf(fid,'\n|    \\/     M anipulation   |                                                 |\n');
    fprintf(fid,'\\*---------------------------------------------------------------------------*/');
    fprintf(fid,'\nFoamFile \n{\n');
    fprintf(fid,'   version     2.0;\n');
    fprintf(fid,'   format      ascii;\n');
    fprintf(fid,'   class       vectorAverageField;\n');
    fprintf(fid,'   location    "constant/boundaryData/mySampleSurface/%s";\n', num2str(time_dir));
    fprintf(fid,'   object      U;\n}\n');
    fprintf(fid,'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
    fprintf(fid,'\n\n');
    fprintf(fid,'//Average\n');
    fprintf(fid,'(0 0 0)\n');
    fclose(fid);       

    system(sprintf('%s %s%s %s%s', 'cp', old_dir, 'U', new_dir, 'U.org'));
    
    system(sprintf('%s %s%s %s%s %s %s%s', 'cat', new_dir, 'header', new_dir, 'U.org', '>', new_dir, 'U'));
    
    system(sprintf('%s %s%s', 'rm', new_dir, 'U.org'));
    
    system(sprintf('%s %s%s', 'rm', new_dir, 'header'));
    
end

system(sprintf('%s %s%s %s%s', 'cp', new_dir, 'mySampleSurface/faceCentres', case_dir, 'points.org')); 

fid = fopen([case_dir 'header'],'w');

fprintf(fid,'/*--------------------------------*- C++ -*----------------------------------*\\');
fprintf(fid,'\n| =========                 |                                                 |');
fprintf(fid,'\n| \\      /  F ield          | OpenFOAM: The Open Source CFD Toolbox           |');
fprintf(fid,'\n|  \\    /   O peration      | Version:  2.3.x                                 |');
fprintf(fid,'\n|   \\  /    A nd            | Web:      http://www.OpenFOAM.com               |');
fprintf(fid,'\n|    \\/     M anipulation   |                                                 |\n');
fprintf(fid,'\\*---------------------------------------------------------------------------*/');
fprintf(fid,'\nFoamFile \n{\n');
fprintf(fid,'   version     2.0;\n');
fprintf(fid,'   format      ascii;\n');
fprintf(fid,'   class       vectorField;\n');
fprintf(fid,'   object      points;\n}\n');
fprintf(fid,'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(fid,'\n');
fclose(fid);

system(sprintf('%s %s%s %s%s %s %s%s', 'cat', case_dir, 'header', case_dir, 'points.org', '>', case_dir, 'points'));

system(sprintf('%s %s%s', 'rm', case_dir, 'points.org'));
system(sprintf('%s %s%s', 'rm', case_dir, 'header'));


for i = 1:num_time
    
    time_dir = (i-1)*stp_time;  
                  
    old_dir = strcat(case_dir, num2str(time_dir), '/mySampleSurface/vectorField/');
    
    new_dir = strcat(case_dir, num2str(time_dir), '/'); 
    
    system(sprintf('%s %s %s%s', 'rm', '-r', new_dir, 'mySampleSurface')); 
    system(sprintf('%s %s %s%s', 'rm', '-r', new_dir, 'vectorField')); 
end
After this you can copy the folder ''mySampleSurface" to the ''constant/boundaryData" of your new case.

Hope this helps.

Best,
Likun
uckmhnds likes this.

Last edited by Likun; October 15, 2015 at 10:07.
Likun is offline   Reply With Quote

Old   October 20, 2015, 14:09
Default
  #6
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by Likun View Post
Dear Syavash,

I also met similar problem before, and I have written a matlab script to add the head to the sampled file.

Suppose your sampleDict reads like this:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      sampleDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

//Example to output facecentres, faces and points for the selected patches

interpolationScheme cellPoint;

surfaceFormat foamFile;

surfaces
(
        mySampleSurface
        {
                type           plane;
                basePoint      (0.01 0.0 0.0);
                normalVector   (1.0 0.0 0.0);
//      type      patch;
//      patches  (OUTLET);
        }
);

//Not really required when run before a simulation as the velocity will be empty.
fields          ( U );

// ************************************************************************* //
After sample you will have many timestep folders under the directory: 'xx/postProcessing/surfaces/' and within each timestep folder you have the sampled surface 'mySampleSurface/'.

Here is the matlab script that I used to add the header and to move the required files directly under the timestep folder.

Code:
num_time = 9; % Total number of timestep folders

stp_time = 1e-4;         % size of timestep

case_dir = 'xx/postProcessing/surfaces/';


for i = 1:num_time

    time_dir = (i-1)*stp_time;  
                  
    old_dir = strcat(case_dir, num2str(time_dir), '/mySampleSurface/vectorField/');
    
    new_dir = strcat(case_dir, num2str(time_dir), '/');
    
    fid = fopen([new_dir 'header'],'w');
    
    fprintf(fid,'/*--------------------------------*- C++ -*----------------------------------*\\');
    fprintf(fid,'\n| =========                 |                                                 |');
    fprintf(fid,'\n| \\      /  F ield          | OpenFOAM: The Open Source CFD Toolbox           |');
    fprintf(fid,'\n|  \\    /   O peration      | Version:  2.3.x                                 |');
    fprintf(fid,'\n|   \\  /    A nd            | Web:      http://www.OpenFOAM.com               |');
    fprintf(fid,'\n|    \\/     M anipulation   |                                                 |\n');
    fprintf(fid,'\\*---------------------------------------------------------------------------*/');
    fprintf(fid,'\nFoamFile \n{\n');
    fprintf(fid,'   version     2.0;\n');
    fprintf(fid,'   format      ascii;\n');
    fprintf(fid,'   class       vectorAverageField;\n');
    fprintf(fid,'   location    "constant/boundaryData/mySampleSurface/%s";\n', num2str(time_dir));
    fprintf(fid,'   object      U;\n}\n');
    fprintf(fid,'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
    fprintf(fid,'\n\n');
    fprintf(fid,'//Average\n');
    fprintf(fid,'(0 0 0)\n');
    fclose(fid);       

    system(sprintf('%s %s%s %s%s', 'cp', old_dir, 'U', new_dir, 'U.org'));
    
    system(sprintf('%s %s%s %s%s %s %s%s', 'cat', new_dir, 'header', new_dir, 'U.org', '>', new_dir, 'U'));
    
    system(sprintf('%s %s%s', 'rm', new_dir, 'U.org'));
    
    system(sprintf('%s %s%s', 'rm', new_dir, 'header'));
    
end

system(sprintf('%s %s%s %s%s', 'cp', new_dir, 'mySampleSurface/faceCentres', case_dir, 'points.org')); 

fid = fopen([case_dir 'header'],'w');

fprintf(fid,'/*--------------------------------*- C++ -*----------------------------------*\\');
fprintf(fid,'\n| =========                 |                                                 |');
fprintf(fid,'\n| \\      /  F ield          | OpenFOAM: The Open Source CFD Toolbox           |');
fprintf(fid,'\n|  \\    /   O peration      | Version:  2.3.x                                 |');
fprintf(fid,'\n|   \\  /    A nd            | Web:      http://www.OpenFOAM.com               |');
fprintf(fid,'\n|    \\/     M anipulation   |                                                 |\n');
fprintf(fid,'\\*---------------------------------------------------------------------------*/');
fprintf(fid,'\nFoamFile \n{\n');
fprintf(fid,'   version     2.0;\n');
fprintf(fid,'   format      ascii;\n');
fprintf(fid,'   class       vectorField;\n');
fprintf(fid,'   object      points;\n}\n');
fprintf(fid,'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(fid,'\n');
fclose(fid);

system(sprintf('%s %s%s %s%s %s %s%s', 'cat', case_dir, 'header', case_dir, 'points.org', '>', case_dir, 'points'));

system(sprintf('%s %s%s', 'rm', case_dir, 'points.org'));
system(sprintf('%s %s%s', 'rm', case_dir, 'header'));


for i = 1:num_time
    
    time_dir = (i-1)*stp_time;  
                  
    old_dir = strcat(case_dir, num2str(time_dir), '/mySampleSurface/vectorField/');
    
    new_dir = strcat(case_dir, num2str(time_dir), '/'); 
    
    system(sprintf('%s %s %s%s', 'rm', '-r', new_dir, 'mySampleSurface')); 
    system(sprintf('%s %s %s%s', 'rm', '-r', new_dir, 'vectorField')); 
end
After this you can copy the folder ''mySampleSurface" to the ''constant/boundaryData" of your new case.

Hope this helps.

Best,
Likun

Dear Likun,

Thank you for sharing your solution.
Unfortunately, Matlab could not recognize 'cp' and 'rm' commands in your scrip! But I am aware that this is an issue with the version installed on my PC!
I could find a workaround. I could make the solver (pimpleFoam) to write the sampled plane (inlet bc) at each time steps. In this way, OpenFoam automatically generates a header with class vectorField just like the following:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       vectorField;
    location    "constant/boundaryData/inlet/0.2";
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Then, I replaced keyword vectorField with vectorAverageField and '960'with '(0 0 0) 960', (960 is the number of faces in inlet bc) respectively using the following commands in linux terminal:
Code:
find ./ -type f -readable -writable -exec sed -i '0,/vectorField/s/vectorField/vectorAverageField/' {} \;
Code:
find ./ -type f -readable -writable -exec sed -i '0,/960/s/960/(0 0 0) 960/' {} \;
These command find and replace the desired keywords. The option '-i' allows the command 'sed' to be executed as 'in place', i.e. find a file in a folder, open and replace the desired word, save and then close to continue searching for another file.

Regards,
Syavash
syavash is offline   Reply With Quote

Old   January 11, 2016, 09:16
Default
  #7
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 66
Rep Power: 12
ali.m.1 is on a distinguished road
Quote:
Originally Posted by syavash View Post
Dear Likun,

Thank you for sharing your solution.
Unfortunately, Matlab could not recognize 'cp' and 'rm' commands in your scrip! But I am aware that this is an issue with the version installed on my PC!
I could find a workaround. I could make the solver (pimpleFoam) to write the sampled plane (inlet bc) at each time steps. In this way, OpenFoam automatically generates a header with class vectorField just like the following:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       vectorField;
    location    "constant/boundaryData/inlet/0.2";
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Then, I replaced keyword vectorField with vectorAverageField and '960'with '(0 0 0) 960', (960 is the number of faces in inlet bc) respectively using the following commands in linux terminal:
Code:
find ./ -type f -readable -writable -exec sed -i '0,/vectorField/s/vectorField/vectorAverageField/' {} \;
Code:
find ./ -type f -readable -writable -exec sed -i '0,/960/s/960/(0 0 0) 960/' {} \;
These command find and replace the desired keywords. The option '-i' allows the command 'sed' to be executed as 'in place', i.e. find a file in a folder, open and replace the desired word, save and then close to continue searching for another file.

Regards,
Syavash
Hi

If you got this to work, do you think it would be possible to run both simulations simultaneously?

So the 'inlet' BC reads the 'outlet' BC while the solver is running?
ali.m.1 is offline   Reply With Quote

Old   January 12, 2016, 11:57
Default
  #8
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
The IOobject class has the member functions writeHeader and readHeader that write the appropriate headers to streams. Since files are abstracted as streams in C++, we can use the IOobject class to write a header to a file. Here is how the application looks like:

Code:
#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"

    IOobject myObject 
    (
        "widget", 
        runTime.timeName(), 
        runTime, 
        IOobject::NO_READ, 
        IOobject::NO_WRITE
    ); 

    // Write the header to the output stream. 
    myObject.writeHeader(Info); 

    // Write the header to a file. 
    OFstream headerFile("myFile"); 
    myObject.writeHeader(headerFile); 

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nEnd\n" << endl;
    return 0;
}
When executed, it will write the header to the output stream, using the global messageStream Info object, and also to the output file stream (file), named "myFile".

If you want to change the parameters of the header, change the IOobject constructor arguments.
__________________
When asking a question, prepare a SSCCE.
tomislav_maric is offline   Reply With Quote

Old   January 12, 2016, 12:56
Default
  #9
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Hi

If you got this to work, do you think it would be possible to run both simulations simultaneously?

So the 'inlet' BC reads the 'outlet' BC while the solver is running?
Ali,

I am not really sure. The above-mentioned solution makes me able to perform a precursor simulation before doing the primary simulation.Adding that my computational resource does not allow me to have two simultaneous simulations!

Besides, I think it is the most appropriate solution for me to save data on a plane in advance, since I would be able to implement the data for as many simulations as I want to perform.

Regards
syavash is offline   Reply With Quote

Old   January 13, 2016, 08:15
Default
  #10
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 66
Rep Power: 12
ali.m.1 is on a distinguished road
Thanks Syavash

I'm planning on trying something like that, but it looks like it's going to be difficult!

regards
ali.m.1 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM.org] Patches to compile OpenFOAM 2.2 on Mac OS X gschaider OpenFOAM Installation 136 October 10, 2017 17:25
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 10:59
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 01:41
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 keepfit ParaView 60 September 18, 2013 03:23
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 10:23


All times are GMT -4. The time now is 20:20.