Commit 21d7f64b authored by Lukas Riedel's avatar Lukas Riedel

initial version using dune-randomfield #7. can only use single value as...

initial version using dune-randomfield #7. can only use single value as correlation length. cannot be parsed by pfg Python script
parent 3ad6640e
......@@ -7,5 +7,5 @@ Module: dorie
Version: 0.9
Maintainer: dorieteam@iup.uni-heidelberg.de
#depending on
Depends: dune-python dune-pdelab
Depends: dune-python dune-pdelab dune-randomfield
Suggests: dune-testtools dune-uggrid
......@@ -33,22 +33,24 @@
#pragma GCC diagnostic pop
// dorie-rfg includes
#include <dune/dorie-rfg/datatypes.hh>
#include <dune/dorie-rfg/Vector.hh>
#include <dune/dorie-rfg/tools.hh>
#if HDF5_PARALLEL
#include <dune/dorie-rfg/H5Tools_parallel.hh>
#else
#include <dune/dorie-rfg/H5Tools_sequential.hh>
#endif
#include <dune/dorie-rfg/FieldData.hh>
#include <dune/dorie-rfg/random_field_generator.hh>
#include <dune/randomfield/randomfield.hh>
/// Traits for the Random Field
template<unsigned int dimension>
struct GridTraits
{
enum {dim = dimension};
using RangeField = double;
using Scalar = Dune::FieldVector<RangeField,1>;
using DomainField = double;
using Domain = Dune::FieldVector<DomainField,dim>;
};
int main(int argc, char** argv)
{
try{
//Initialize Mpi
Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
Dune::MPIHelper::instance(argc, argv);
if (argc!=2)
DUNE_THROW(Dune::IOError,"No parameter file specified!");
......@@ -72,28 +74,32 @@ int main(int argc, char** argv)
if (result != 0)
DUNE_THROW(Dune::IOError,"Output folder " << outputPath << " not writable");
const std::string outputFile = outputPath + "YField";
// comply to dune-randomfield config file scheme
inifile["grid.extensions"] = inifile["generator.extensions"];
inifile["grid.cells"] = inifile["generator.fft.N"];
inifile["stochastic.variance"] = inifile["generator.variance"];
inifile["stochastic.corrLength"] = inifile["generator.fft.correlationLengths"];
inifile["stochastic.covariance"] = inifile["generator.fft.variogramModel"];
// Create RFG objects
switch(dim){
case 2:
{
typedef Dune::Dorie::FieldData<REAL,2> FD;
FD fielddata;
fielddata.read(inifile);
fielddata.printInfos();
typedef Dune::Dorie::FFTFieldGenerator<FD,REAL,REAL*,2> YFG;
YFG yfg(fielddata, helper.getCommunicator());
yfg.init();
using Traits = GridTraits<2>;
Dune::RandomField::RandomField<Traits,false,false> field(inifile);
field.generate();
field.writeToFile(outputFile);
}
break;
case 3:
{
typedef Dune::Dorie::FieldData<REAL,3> FD;
FD fielddata;
fielddata.read(inifile);
fielddata.printInfos();
typedef Dune::Dorie::FFTFieldGenerator<FD,REAL,REAL*,3> YFG;
YFG yfg(fielddata, helper.getCommunicator());
yfg.init();
using Traits = GridTraits<3>;
Dune::RandomField::RandomField<Traits,false,false> field(inifile);
field.generate();
field.writeToFile(outputFile);
}
break;
default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment