Skip to content

Uploading data

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1998
    kolotinsky
    Participant

    Hello everybody,
    I have the following question. I want to create simulation with external force. However, this force is given numerically in data file. Could you help me to upload it for my purpose? Should I create a new functor or change any existing functor? May be is it possible to overcome my task without overwriting anything? Please, if it is possible, give detailed response because I am still beginner in openlb.
    kolotinsky

    #2937
    mlm
    Participant

    Hello kolotinsky,
    you can use the already existing vti reader in src/io/vtiReader.h for your purpose to load the data into your external field:
    “The VTI reader is able to read from VTI files and create and fill corresponding data structures. The reading process starts with the construction of the reader object. The name of the data type to be read (e.g. “physVelocity”) is mandatory.”

    #2942
    kolotinsky
    Participant

    Dear mlm,
    could you tell me in more detail how can I create my own VTI file and in particular how can I read the information from this file and apply it for my purpose?

    #2949
    mathias
    Keymaster

    vti is a vtk format (see https://www.vtk.org/ ) for more information. There are Phyton interfaces which are quite nice. Within OpenLB you use already implemented interfaces for setting external field like forces:

    /// Define an external field on a domain described by an indicator
    /**
    * \param indicator Indicator describing the target domain
    * \param fieldBeginsAt Field offset
    * \param sizeOfField Target dimension of field functor
    * \param field Analytical functor
    **/
    void defineExternalField(FunctorPtr<SuperIndicatorF3D<T>>&& indicator,
    int fieldBeginsAt, int sizeOfField, AnalyticalF3D<T,T>& field);
    /// Define an external field on a domain with a particular material number
    void defineExternalField(SuperGeometry3D<T>& sGeometry, int material,
    int fieldBeginsAt, int sizeOfField, AnalyticalF3D<T,T>& field);
    /// Define an external field on a Indicator domain
    /**
    * \param indicatorF Domain indicator to be reduced
    **/
    void defineExternalField(SuperGeometry3D<T>& sGeometry, IndicatorF3D<T>& indicatorF,
    int fieldBeginsAt, int sizeOfField, AnalyticalF3D<T,T>& field);
    /// Define an external field on a domain with a particular material number
    void defineExternalField(SuperGeometry3D<T>& sGeometry, int material,
    int fieldBeginsAt, int sizeOfField, SuperF3D<T,T>& field);

    Please, have a look into the dogyget documentation which helps a loot finding the right interfaces.

    Best
    Mathias

    #2965
    kolotinsky
    Participant

    As I understand I need to load my data into an AnalyticalF3D object. Initially my force field is located in a vti file. Thus my key question is: how to fill AnalyticalF3D object using the data from the vti file?

    #2966
    fk
    Participant

    Hi,

    lets assume you have following VTI file:

    Quote:
    dataFile.vti
    Code:
    <VTKFile byte_order=”LittleEndian” type=”ImageData” version=”0.1″>
    <ImageData Origin=”-0.0014 0.01 0.0040″ Spacing=”0.00004 0.00004 1″ WholeExtent=”0 255 0 255 0 0″>
    <Piece Extent=”0 255 0 255 0 0″>
    <PointData>
    <DataArray Name=”physVelocity” NumberOfComponents=”3″ format=”ascii” type=”Float32″>

    You can then use the BlockVTIreader, and the BlockDataF3D, using the properties of the VTI file (filename “dataFile.vti” and DataArray name “physVelocity”):

    Code:
    BlockVTIreader3D<T,BaseType> readerData(“dataFile.vti”, “physVelocity”);
    BlockDataF3D<T,BaseType> velocityF(readerData.getBlockData());

    Then use the SpecialAnayticalF functor, for non-uniform grids, or the AnalyticalF functor to interpolate your data:

    Code:
    AnalyticalF3D<T,T>* solution;
    solution = new SpecialAnalyticalFfromBlockF3D<T,BaseType>(velocityF, readerData.getCuboid(), spacing);

    Where spacing is a Vector object, with the spacing information of the VTI file.

    Code:
    // Spacing=”0.00004 0.00004 1″
    Vector<T,3> spacing(0.00004, 0.00004, 1);

    Best,
    Fabian

    #2968
    kolotinsky
    Participant

    Dear Fabian, following your example I have written code for my case:

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Initialize force

    std::vector<T> spacing(3, T());
    spacing[0] = 1;
    spacing[1] = 1;
    spacing[2] = 1;

    olb::BlockVTIreader3D< T, BaseType > datareader(“forcefield.vti”,”AppendedData”);
    BlockDataF3D<T, BaseType> blockfield(datareader.getBlockData());
    AnalyticalF3D<T,T>* field;
    field = new SpecialAnalyticalFfromBlockF3D<T,BaseType>(blockfield, datareader.getCuboid(), spacing);
    sLattice.defineExternalField( superGeometry, 1,
    DESCRIPTOR<T>::ExternalField::forceBeginsAt,
    DESCRIPTOR<T>::ExternalField::sizeOfForce, *field );
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    However, during the simulation I am receiving wrong zero or NaN values of Energy and Umax:

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    [LatticeStatistics] step=190; t=190; uMax=0; avEnergy=nan; avRho=nan
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    I have verified my vti file in Paraview but everything is ok.

    I also tried to write the data uploaded from my vti file using vtiWriter provided by OpenLB:

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    olb::VTIwriter3D< T, BaseType > datawriter;
    datawriter.writeData(“field”,”AppendedData”,datareader.getBlockData(),datareader.getCuboid());
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Generated force.vti file contains only the following data:

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    <?xml version=”1.0″?>
    <VTKFile type=”ImageData” version=”0.1″ byte_order=”LittleEndian”>
    <ImageData WholeExtent=” 0 49 0 49 0 49 ” Origin=”0 0 0″ Spacing=”1 1 1″>
    <Piece Extent=”0 49 0 49 0 49″>
    <PointData>
    <DataArray type=”Float32″ Name=”AppendedData” NumberOfComponents=”0″>
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    What is wrong?

    #2969
    fk
    Participant

    It is hard say without seeing the VTI file, but due to the DataArray name “AppendedData”, it looks like the format of the file is incompatible with the BlockVTIreader.

    I would suggest to save your data in Ascii format, without compression. This can be done using ParaView using “Save Data” and then “Ascii” as “Data Format”.

    #2970
    kolotinsky
    Participant

    Dear Fabian,
    I have changed my vti data from Appended to Ascii:

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    <VTKFile type=”ImageData” version=”1.0″ byte_order=”LittleEndian” header_type=”UInt64″>
    <ImageData WholeExtent=”-1 50 -1 50 -1 50″ Origin=”0 0 0″ Spacing=”1 1 1″>
    <Piece Extent=”-1 50 -1 50 -1 50″>
    <PointData>
    <DataArray type=”Float64″ Name=”ForceField” NumberOfComponents=”3″ format=”ascii” RangeMin=”0.00014142135266500606″ RangeMax=”0.00014142135266500606″>
    0.000099999997474 0.000099999997474 0 0.000099999997474 0.000099999997474 0
    0.000099999997474 0.000099999997474 0 0.000099999997474 0.000099999997474 0
    ……………………………………………………………………………………………………………………………………………
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Now vtiReader reads my data correctly, but on the step “define external field” I have segmentation fault in case of such
    definition:

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    std::vector<T> spacing(3, T());
    spacing[0] = 1;
    spacing[1] = 1;
    spacing[2] = 1;
    olb::BlockVTIreader3D< T, BaseType > datareader(“forcefield.vti”,”ForceField”);
    BlockDataF3D<T, BaseType> blockfield(datareader.getBlockData());
    AnalyticalF3D<T,T>* field;
    field = new SpecialAnalyticalFfromBlockF3D<T,BaseType>(blockfield, datareader.getCuboid(), spacing);
    sLattice.defineExternalField( superGeometry, 1,
    DESCRIPTOR<T>::ExternalField::forceBeginsAt,
    DESCRIPTOR<T>::ExternalField::sizeOfForce, *field );
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    I also tried to define force field such way:

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    olb::BlockVTIreader3D< T, BaseType > datareader(“forcefield.vti”,”ForceField”);
    BlockDataF3D<T, BaseType> blockfield(datareader.getBlockData());
    AnalyticalF3D<T,T>* field;
    field = new AnalyticalFfromBlockF3D<T,BaseType>(blockfield, datareader.getCuboid(), 0);
    sLattice.defineExternalField( superGeometry, 1,
    DESCRIPTOR<T>::ExternalField::forceBeginsAt,
    DESCRIPTOR<T>::ExternalField::sizeOfForce, *field );
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    In this case I don’t get segmentation fault, but my system’s behaviour is wrong. To find out if the external field was written correctly I generated file contained external field using SuperVtmWriter3D:

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    SuperVTMwriter3D<T> vtmWriter( “ionwake3d” );

    SuperLatticeExternalField3D<T, DESCRIPTOR> force( sLattice, DESCRIPTOR<T>::ExternalField::forceBeginsAt,
    DESCRIPTOR<T>::ExternalField::sizeOfForce );
    vtmWriter.addFunctor( force );
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    This generated file doesn’t math up with uploaded:

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    <VTKFile type=”ImageData” version=”1.0″ byte_order=”LittleEndian” header_type=”UInt64″>
    <ImageData WholeExtent=”-1 50 -1 50 -1 50″ Origin=”0 0 0″ Spacing=”1 1 1″>
    <Piece Extent=”-1 50 -1 50 -1 50″>
    <PointData>
    <DataArray type=”Float32″ Name=”externalField” NumberOfComponents=”3″ format=”ascii” RangeMin=”0″ RangeMax=”18.759683655122647″>
    0 0 0 0 0 0
    0.26010000705718994 0.26010000705718994 0 0.5202000141143799 0.5202000141143799 0
    0.780299961566925 0.780299961566925 0 1.0404000282287598 1.0404000282287598 0
    1.3004999160766602 1.3004999160766602 0 1.56059992313385 1.56059992313385 0
    ……………………………………………………………………………………………………………………………………………………………..

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    I think it is also important to say a few words about my system. Now I’m using uniform 50*50*50 grid with periodic boundary conditions.

    By the way , is it comfortable for you to communicate via email or any social network? It will allow me to describe the problem in more details and attach required files. I suppose it will make our dialog more effective.
    If yes this is my mail address: kolotinsky.daniil1998@gmail.com

    Sincerely,
    Daniil Kolotinsky

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.