Skip to content
Snippets Groups Projects
Commit 438be1ad authored by Xavier Adriaens's avatar Xavier Adriaens
Browse files

Initial commit (reproducing result of paper 1)

parents
No related branches found
No related tags found
No related merge requests found
#ifndef H_SPECIFIC_WAVE_NEWEQUATION
#define H_SPECIFIC_WAVE_NEWEQUATION
//Standard Library
#include <string>
//GmshFem Library
#include "GmshFem.h"
#include "Exception.h"
//FWI Library
#include "helmholtz.h"
template<Physic T_Physic>
EquationInterface<T_Physic>* newEquation(double pulsation, const ConfigurationInterface* const config, const wave::Discretization<T_Physic>& w_discret, const gmshfem::common::GmshFem& gmshFem);
/* acoustic */
template<>
EquationInterface<Physic::acoustic>* newEquation(double pulsation, const ConfigurationInterface* const config, const wave::Discretization<Physic::acoustic>& w_discret, const gmshfem::common::GmshFem& gmshFem)
{
std::string equation;
if(!gmshFem.userDefinedParameter(equation, "equation"))
{
throw gmshfem::common::Exception("Equation type could not be found.");
}
if(equation=="helmholtz"){return new helmholtz::Equation(pulsation,config,w_discret,gmshFem);}
else
{
throw gmshfem::common::Exception("Equation " + equation + " is not valid in acoustics.");
return nullptr;
}
};
#endif //H_SPECIFIC_WAVE_NEWEQUATION
//GmshFem Library
#include "Integrate.h"
#include "Function.h"
//FWI Library
#include "wavetodata.h"
using namespace gmshfem::post;
using namespace gmshfem::function;
template<>
Data<Physic::acoustic> wave_to_data(const ConfigurationInterface* const config, const WaveMultiField<Physic::acoustic>& w)
{
Data<Physic::acoustic> v(config);
for (unsigned int s = 0; s < config->ns(); s++)
{
for (unsigned int r = 0; r < config->nr(s); r++)
{
PointData<Physic::acoustic> buffer(integrate(1.0*w[s],config->receiver(s,r),"Gauss1"));
v.value(s,r,buffer);
}
}
return v;
}
#ifndef H_SPECIFIC_RESTRICTION
#define H_SPECIFIC_RESTRICTION
#include "../common/data/element.h"
#include "../common/wave/element.h"
template<Physic T_Physic>
Data<T_Physic> wave_to_data(const ConfigurationInterface* const config, const WaveMultiField<T_Physic>& w);
#endif // H_SPECIFIC_RESTRICTION
//GmshFem Library
#include "GmshFem.h"
#include "Post.h"
using namespace gmshfem;
using namespace gmshfem::common;
using namespace gmshfem::post;
//FWI Library
#include "common/data/updater.h"
#include "common/wave/updater.h"
#include "specific/physic.h"
#include "specific/configuration/newConfiguration.h"
#include "specific/wave/equation/newEquation.h"
template<Physic T_Physic>
int synthetics(const GmshFem& gmshFem)
{
std::string name = "noname";
gmshFem.userDefinedParameter(name, "name");
ConfigurationInterface* configuration = newConfiguration(gmshFem);
save(configuration->m0(), configuration->model_known(Support::BLK), name+"_m_syn_blk", "pos", "");
save(configuration->m0(), configuration->model_known(Support::BND), name+"_m_syn_bnd", "pos", "");
wave::Discretization<T_Physic> w_discret(gmshFem);
double frequency = 0.;
if(!gmshFem.userDefinedParameter(frequency, "frequency"))
{
throw Exception("Frequency could not be found.");
}
msg::print << "Generate synthetic data at frequency = " << frequency << msg::endl;
EquationInterface<T_Physic>* const equation = newEquation(2.*M_PI*frequency,configuration,w_discret,gmshFem);
WaveUpdater<T_Physic> wu(configuration,nullptr,equation);
DataUpdater<T_Physic> du(configuration,&wu,nullptr);
ModelState ms(configuration);
std::array<bool,4> needUpToDate = {true,false,false,false};
((du.get(needUpToDate,ms)).state(Type::F)).write(name+"_data");
wu.get(needUpToDate,ms).write(Type::F,name+"_u_syn");
delete equation;
delete configuration;
return 0;
}
int main(int argc, char **argv)
{
GmshFem gmshFem(argc, argv);
Physic T_Physic = to_physic(gmshFem);
switch (T_Physic)
{
case Physic::acoustic: default:
return synthetics<Physic::acoustic>(gmshFem);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment