Commit 106e5903 authored by Markus Wiedemann's avatar Markus Wiedemann
Browse files

vtk output in app

parent 364b0fc3
Pipeline #40969 failed with stages
in 10 minutes and 53 seconds
...@@ -116,17 +116,10 @@ ConvectionSimulation::ConvectionSimulation( const walberla::Config::BlockHandle& ...@@ -116,17 +116,10 @@ ConvectionSimulation::ConvectionSimulation( const walberla::Config::BlockHandle&
m_fDensity = [&]( const Point3D& x ) { m_fDensity = [&]( const Point3D& x ) {
real_t retVal; real_t retVal;
if ( m_variableParam.haveDensityProfile ) retVal = m_inputParam.density;
{
auto radius = std::sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] );
retVal = linear_interpolate_between( m_inputParam.densityProfile, radius );
}
else
{
retVal = m_inputParam.density;
}
return retVal; return retVal;
}; };
m_fConductivity = [&]( const Point3D& x ) { return m_inputParam.thermal_conductivity; }; m_fConductivity = [&]( const Point3D& x ) { return m_inputParam.thermal_conductivity; };
}; };
...@@ -159,6 +152,12 @@ void ConvectionSimulation::parseConfig( const walberla::Config::BlockHandle& mai ...@@ -159,6 +152,12 @@ void ConvectionSimulation::parseConfig( const walberla::Config::BlockHandle& mai
if ( readDataFile( fileDensityProfile, m_inputParam.densityProfile, 2 ) ) if ( readDataFile( fileDensityProfile, m_inputParam.densityProfile, 2 ) )
{ {
m_variableParam.haveDensityProfile = true; m_variableParam.haveDensityProfile = true;
m_fDensity = [&]( const Point3D& x ) {
real_t retVal;
auto radius = std::sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] );
retVal = linear_interpolate_between( m_inputParam.densityProfile, radius );
return retVal;
};
} }
} }
else if ( mainConf.isDefined( "density" ) ) else if ( mainConf.isDefined( "density" ) )
...@@ -172,6 +171,12 @@ void ConvectionSimulation::parseConfig( const walberla::Config::BlockHandle& mai ...@@ -172,6 +171,12 @@ void ConvectionSimulation::parseConfig( const walberla::Config::BlockHandle& mai
if ( readDataFile( fileTemperatureProfile, m_inputParam.temperatureProfile, 2 ) ) if ( readDataFile( fileTemperatureProfile, m_inputParam.temperatureProfile, 2 ) )
{ {
m_variableParam.haveTemperatureProfile = true; m_variableParam.haveTemperatureProfile = true;
m_fInitalTemperature = [&]( const Point3D& x ) {
real_t retVal;
auto radius = std::sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] );
retVal = linear_interpolate_between( m_inputParam.temperatureProfile, radius );
return retVal;
};
} }
} }
else if ( mainConf.isDefined( "cmb_temp" ) && mainConf.isDefined( "surface_temp" ) && else if ( mainConf.isDefined( "cmb_temp" ) && mainConf.isDefined( "surface_temp" ) &&
...@@ -186,8 +191,7 @@ void ConvectionSimulation::parseConfig( const walberla::Config::BlockHandle& mai ...@@ -186,8 +191,7 @@ void ConvectionSimulation::parseConfig( const walberla::Config::BlockHandle& mai
<< "Specify profile for temperature! Continuing with cmb_temp of 4200, surface_tmp of 300 and initialTemperatureSteepness of 10" << "Specify profile for temperature! Continuing with cmb_temp of 4200, surface_tmp of 300 and initialTemperatureSteepness of 10"
<< std::endl; << std::endl;
if ( mainConf.isDefined( "fileViscosityProfile" ) )
if (mainConf.isDefined( "fileViscosityProfile" ) )
{ {
std::string fileViscosityProfile = mainConf.getParameter< std::string >( "fileViscosityProfile" ); std::string fileViscosityProfile = mainConf.getParameter< std::string >( "fileViscosityProfile" );
if ( readDataFile( fileViscosityProfile, m_inputParam.viscosityProfile, 2 ) ) if ( readDataFile( fileViscosityProfile, m_inputParam.viscosityProfile, 2 ) )
...@@ -231,9 +235,6 @@ void ConvectionSimulation::parseConfig( const walberla::Config::BlockHandle& mai ...@@ -231,9 +235,6 @@ void ConvectionSimulation::parseConfig( const walberla::Config::BlockHandle& mai
m_outputParam.vtkOutputVertexDoFs = mainConf.getParameter< bool >( "vtkOutputVertexDoFs" ); m_outputParam.vtkOutputVertexDoFs = mainConf.getParameter< bool >( "vtkOutputVertexDoFs" );
m_verbose = mainConf.getParameter< bool >( "verbose" ); m_verbose = mainConf.getParameter< bool >( "verbose" );
m_outputParam.outputDirectory = mainConf.getParameter< std::string >( "outputDirectory" );
m_outputParam.outputBaseName = mainConf.getParameter< std::string >( "outputBaseName" );
} }
void ConvectionSimulation::createSetupStorage() void ConvectionSimulation::createSetupStorage()
...@@ -347,13 +348,6 @@ void ConvectionSimulation::initialiseFunctions() ...@@ -347,13 +348,6 @@ void ConvectionSimulation::initialiseFunctions()
void ConvectionSimulation::setupSolversAndOperators() void ConvectionSimulation::setupSolversAndOperators()
{ {
// 7
// m_pStokesSolver = solvertemplates::stokesMinResSolver< StokesOperator >( m_pStorage,
// m_domainInfo.minLevel,
// m_solverInfo.stokesAbsoluteResidualUTolerance,
// m_solverInfo.stokesMaxNumIterations,
// m_verbose );
auto prolongationOperator = std::make_shared< P2P1StokesToP2P1StokesProlongation >(); auto prolongationOperator = std::make_shared< P2P1StokesToP2P1StokesProlongation >();
auto restrictionOperator = std::make_shared< P2P1StokesToP2P1StokesRestriction >( true ); auto restrictionOperator = std::make_shared< P2P1StokesToP2P1StokesRestriction >( true );
...@@ -437,47 +431,53 @@ void ConvectionSimulation::setupSolversAndOperators() ...@@ -437,47 +431,53 @@ void ConvectionSimulation::setupSolversAndOperators()
m_pParticleTracker = std::make_shared< particleTracker::ParticleTracker< ScalarFunction > >( m_pParticleTracker = std::make_shared< particleTracker::ParticleTracker< ScalarFunction > >(
m_pStorage, m_domainParam.minLevel, m_domainParam.maxLevel, particleTracker::TimeSteppingScheme::RK4, 100000 ); m_pStorage, m_domainParam.minLevel, m_domainParam.maxLevel, particleTracker::TimeSteppingScheme::RK4, 100000 );
}
void ConvectionSimulation::setupOutput()
{
auto vtkOutputParticles = auto vtkOutputParticles =
std::make_shared< walberla::convection_particles::vtk::ParticleVtkOutput >( m_pParticleTracker->getStorage() ); std::make_shared< walberla::convection_particles::vtk::ParticleVtkOutput >( m_pParticleTracker->getStorage() );
auto vtkWriter = walberla::vtk::createVTKOutput_PointData( m_pVtkOutputParticles = walberla::vtk::createVTKOutput_PointData(
vtkOutputParticles, "cnt", 1, m_outputParam.outputDirectory, "simulation_step", true, true, true, true ); vtkOutputParticles, "cnt", 1, m_outputParam.outputDirectory, "simulation_step", true, true, true, true );
// hyteg::VTKOutput vtkOutput( outputDirectory, outputBaseName, storage, vtkInterval ); m_pVtkOutput = std::make_shared<hyteg::VTKOutput>( m_outputParam.outputDirectory, m_outputParam.outputBaseName, m_pStorage, m_outputParam.vtkOutputInterval );
// vtkOutput.setVTKDataFormat( hyteg::vtk::DataFormat::BINARY ); m_pVtkOutput->setVTKDataFormat( hyteg::vtk::DataFormat::BINARY );
// if ( vtkOutputVertexDoFs ) if ( m_outputParam.vtkOutputVertexDoFs )
// { {
// vtkOutput.add( temperature.getVertexDoFFunction() ); m_pVtkOutput->add( m_pTemperature->getVertexDoFFunction() );
// } }
// else else
// { {
// vtkOutput.add( temperature ); m_pVtkOutput->add( *m_pTemperature );
// } }
// if ( vtkOutputVelocity ) if ( m_outputParam.vtkOutputVelocity )
// { {
// if ( vtkOutputVertexDoFs ) if ( m_outputParam.vtkOutputVertexDoFs )
// { {
// vtkOutput.add( u.uvw()[0].getVertexDoFFunction() ); m_pVtkOutput->add( m_pU->uvw()[0].getVertexDoFFunction() );
// vtkOutput.add( u.uvw()[1].getVertexDoFFunction() ); m_pVtkOutput->add( m_pU->uvw()[1].getVertexDoFFunction() );
// vtkOutput.add( u.uvw()[2].getVertexDoFFunction() ); m_pVtkOutput->add( m_pU->uvw()[2].getVertexDoFFunction() );
// } }
// else else
// { {
// vtkOutput.add( u ); m_pVtkOutput->add( *m_pU );
// } }
// } }
// else else
// { {
// if ( vtkOutputVertexDoFs ) if ( m_outputParam.vtkOutputVertexDoFs )
// { {
// vtkOutput.add( uMagnitudeSquared.getVertexDoFFunction() ); m_pVtkOutput->add( m_pUMagnitudeSquared->getVertexDoFFunction() );
// } }
// else else
// { {
// vtkOutput.add( uMagnitudeSquared ); m_pVtkOutput->add( *m_pUMagnitudeSquared );
// } }
// } }
} }
void ConvectionSimulation::step() void ConvectionSimulation::step()
...@@ -556,6 +556,18 @@ void ConvectionSimulation::step() ...@@ -556,6 +556,18 @@ void ConvectionSimulation::step()
this->prepareRHSMassAndMomentum(); this->prepareRHSMassAndMomentum();
m_pStokesSolver->solve( *m_pStokesOperator, *m_pU, *m_pF, m_domainParam.maxLevel ); m_pStokesSolver->solve( *m_pStokesOperator, *m_pU, *m_pF, m_domainParam.maxLevel );
// ##################
// Write Output
if ( m_outputParam.vtk )
{
m_pVtkOutput->write( m_domainParam.maxLevel, m_timestep );
m_pVtkOutputParticles->write( m_domainParam.maxLevel, m_timestep );
}
++m_timestep; ++m_timestep;
} }
...@@ -697,7 +709,11 @@ void ConvectionSimulation::updateViscosity() ...@@ -697,7 +709,11 @@ void ConvectionSimulation::updateViscosity()
{ {
m_pViscosity->interpolate( update, { *m_pTemperature }, All ); m_pViscosity->interpolate( update, { *m_pTemperature }, All );
} }
} }
else
{
return;
}
} }
} // namespace hyteg } // namespace hyteg
...@@ -175,14 +175,13 @@ struct InputParameters ...@@ -175,14 +175,13 @@ struct InputParameters
real_t diffusivity = 3; real_t diffusivity = 3;
real_t thermal_expansivity = 2.238 * 1e-5; real_t thermal_expansivity = 2.238 * 1e-5;
real_t thermal_conductivity = 3.0; real_t thermal_conductivity = 3.0;
real_t specific_heat_capacity = 1079; real_t specific_heat_capacity = 1.1 * 1e3;
real_t internal_heating_rate = 3.0; real_t internal_heating_rate = 3.0;
real_t density = 1.0; real_t density = 1.0;
real_t viscosity = 1.0; real_t viscosity = 1.0;
real_t rayleighNumber = 1e6; real_t rayleighNumber = 1e6;
real_t alpha = 1.f; real_t alpha = 2.238 * 1e-5f;
real_t activation_energy = 0.1f; real_t activation_energy = 0.1f;
}; };
...@@ -233,6 +232,12 @@ class ConvectionSimulation ...@@ -233,6 +232,12 @@ class ConvectionSimulation
*/ */
void setupSolversAndOperators(); void setupSolversAndOperators();
/**
* @brief Set up output
*
*/
void setupOutput();
/** /**
* @brief Parse the given config into member variables * @brief Parse the given config into member variables
* *
...@@ -353,6 +358,11 @@ class ConvectionSimulation ...@@ -353,6 +358,11 @@ class ConvectionSimulation
std::shared_ptr< MMOCTransport< ScalarFunction > > m_pTransport; std::shared_ptr< MMOCTransport< ScalarFunction > > m_pTransport;
std::shared_ptr< particleTracker::ParticleTracker< ScalarFunction > > m_pParticleTracker; std::shared_ptr< particleTracker::ParticleTracker< ScalarFunction > > m_pParticleTracker;
std::shared_ptr<hyteg::VTKOutput> m_pVtkOutput;
std::shared_ptr<walberla::vtk::VTKOutput> m_pVtkOutputParticles;
// std::functions for various functionalities // std::functions for various functionalities
std::function< real_t( const Point3D& ) > m_fViscosity; std::function< real_t( const Point3D& ) > m_fViscosity;
std::function< real_t( const Point3D& ) > m_fInitalTemperature; std::function< real_t( const Point3D& ) > m_fInitalTemperature;
......
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