Commit 1d77e8c9 authored by Tilman Steinweg's avatar Tilman Steinweg
Browse files

Merge branch 'develop' into feature/lama_v3

Conflicts:
	src/Wavefields/Wavefields.hpp
	src/Wavefields/Wavefields2Dacoustic.hpp
	src/Wavefields/Wavefields2Delastic.hpp
	src/Wavefields/Wavefields2Dvisco.hpp
	src/Wavefields/Wavefields3Dacoustic.hpp
	src/Wavefields/Wavefields3Delastic.hpp
	src/Wavefields/Wavefields3Dvisco.hpp
parents 33a629dc 5900b5c3
*
\ No newline at end of file
*.mtx
*.txt
......@@ -57,3 +57,9 @@ SeismogramFilename=ci/seismogram.2D.acoustic.ci
SeismogramFormat=1 # 1=MTX, 2=SU
NormalizeTraces=0 # 1=Normalize Traces of the Seismogram, 0=Not Normalized
runSimultaneousShots=1 # 1=All sources specified in SourceFilename are triggerd simultaneously
# wavefield snapshots
saveSnapshots=0 # 1=Yes, 0=No
tFirstSnapshot=0 # Time of first snapshot in seconds
tLastSnapshot=2 # Time of last snapshot in seconds
tIncSnapshot=1 # Time increment between snapshot in seconds
......@@ -58,3 +58,8 @@ SeismogramFormat=1 # 1=MTX, 2=SU
NormalizeTraces=0 # 1=Normalize Traces of the Seismogram, 0=Not Normalized
runSimultaneousShots=1 # 1=All sources specified in SourceFilename are triggerd simultaneously
# wavefield snapshots
saveSnapshots=0 # 1=Yes, 0=No
tFirstSnapshot=0 # Time of first snapshot in seconds
tLastSnapshot=2 # Time of last snapshot in seconds
tIncSnapshot=1 # Time increment between snapshot in seconds
......@@ -57,3 +57,9 @@ SeismogramFilename=ci/seismogram.2D.visco.ci
SeismogramFormat=1 # 1=MTX, 2=SU
NormalizeTraces=0 # 1=Normalize Traces of the Seismogram, 0=Not Normalized
runSimultaneousShots=1 # 1=All sources specified in SourceFilename are triggerd simultaneously
# wavefield snapshots
saveSnapshots=0 # 1=Yes, 0=No
tFirstSnapshot=0 # Time of first snapshot in seconds
tLastSnapshot=2 # Time of last snapshot in seconds
tIncSnapshot=1 # Time increment between snapshot in seconds
......@@ -57,3 +57,9 @@ SeismogramFilename=ci/seismogram.3D.acoustic.ci
SeismogramFormat=1 # 1=MTX, 2=SU
NormalizeTraces=0 # 1=Normalize Traces of the Seismogram, 0=Not Normalized
runSimultaneousShots=1 # 1=All sources specified in SourceFilename are triggerd simultaneously
# wavefield snapshots
saveSnapshots=0 # 1=Yes, 0=No
tFirstSnapshot=0 # Time of first snapshot in seconds
tLastSnapshot=2 # Time of last snapshot in seconds
tIncSnapshot=1 # Time increment between snapshot in seconds
......@@ -57,3 +57,9 @@ SeismogramFilename=ci/seismogram.3D.elastic.ci
SeismogramFormat=1 # 1=MTX, 2=SU
NormalizeTraces=0 # 1=Normalize Traces of the Seismogram, 0=Not Normalized
runSimultaneousShots=1 # 1=All sources specified in SourceFilename are triggerd simultaneously
# wavefield snapshots
saveSnapshots=0 # 1=Yes, 0=No
tFirstSnapshot=0 # Time of first snapshot in seconds
tLastSnapshot=2 # Time of last snapshot in seconds
tIncSnapshot=1 # Time increment between snapshot in seconds
......@@ -58,3 +58,8 @@ SeismogramFormat=1 # 1=MTX, 2=SU
NormalizeTraces=0 # 1=Normalize Traces of the Seismogram, 0=Not Normalized
runSimultaneousShots=1 # 1=All sources specified in SourceFilename are triggerd simultaneously
# wavefield snapshots
saveSnapshots=0 # 1=Yes, 0=No
tFirstSnapshot=0 # Time of first snapshot in seconds
tLastSnapshot=2 # Time of last snapshot in seconds
tIncSnapshot=1 # Time increment between snapshot in seconds
......@@ -68,3 +68,10 @@ SeismogramFilename=seismograms/seismogram # target location of seismogram
SeismogramFormat=1 # 1=MTX, 2=SU
NormalizeTraces=0 # 1=Normalize Traces of the Seismogram, 0=Not Normalized
runSimultaneousShots=0 # 1=All sources specified in SourceFilename are triggerd simultaneously
# wavefield snapshots
saveSnapshots=1 # 1=Yes, 0=No
WavefieldFileName=wavefields/wavefield # location of wavefields
tFirstSnapshot=0 # Time of first snapshot in seconds
tLastSnapshot=2 # Time of last snapshot in seconds
tIncSnapshot=0.5 # Time increment between snapshot in seconds
......@@ -52,9 +52,17 @@ int main(int argc, const char *argv[])
std::string dimension = config.get<std::string>("dimension");
std::string equationType = config.get<std::string>("equationType");
IndexType timeStepsBetweenSnapshots = static_cast<IndexType>(config.get<ValueType>("timeStepsBetweenSnapshots"));
IndexType tEnd = static_cast<IndexType>((config.get<ValueType>("T") / config.get<ValueType>("DT")) + 0.5);
IndexType t = 0;
// following lines should be in a extra function in check parameter class
IndexType tStepEnd = static_cast<IndexType>((config.get<ValueType>("T") / config.get<ValueType>("DT")) + 0.5);
IndexType firstSnapshot = 0, lastSnapshot = 0, incSnapshot = 0 ;
if (config.get<bool>("saveSnapshots")==1){
firstSnapshot = static_cast<IndexType>(config.get<ValueType>("tFirstSnapshot") / config.get<ValueType>("DT") + 0.5);
lastSnapshot = static_cast<IndexType>(config.get<ValueType>("tLastSnapshot") / config.get<ValueType>("DT") + 0.5);
incSnapshot = static_cast<IndexType>(config.get<ValueType>("tIncSnapshot") / config.get<ValueType>("DT") + 0.5);
}
IndexType partitionedOut = static_cast<IndexType>(config.get<ValueType>("PartitionedOut"));
/* --------------------------------------- */
......@@ -66,6 +74,13 @@ int main(int argc, const char *argv[])
/* execution context */
hmemo::ContextPtr ctx = hmemo::Context::getContextPtr(); // default context, set by environment variable SCAI_CONTEXT
// following lines should be part of checkParameter.tpp
if (comm->getSize()!=config.get<IndexType>("ProcNX")*config.get<IndexType>("ProcNY")*config.get<IndexType>("ProcNZ"))
{
HOST_PRINT(comm, "\n Error: Number of MPI processes (" << comm->getSize() << ") doesn't match the number of processes specified in " << argv[1] << ": ProcNX*ProcNY*ProcNZ=" << config.get<IndexType>("ProcNX")*config.get<IndexType>("ProcNY")*config.get<IndexType>("ProcNZ") << "\n")
return(2);
}
// inter node distribution
// define the grid topology by sizes NX, NY, and NZ from configuration
// Attention: LAMA uses row-major indexing while SOFI-3D uses column-major, so switch dimensions, x-dimension has stride 1
......@@ -115,7 +130,7 @@ int main(int argc, const char *argv[])
/* Forward solver */
/* --------------------------------------- */
ForwardSolver::ForwardSolver<ValueType>::ForwardSolverPtr solver(ForwardSolver::Factory<ValueType>::Create(dimension, equationType));
solver->prepareBoundaryConditions(config, *derivatives, dist, ctx);
......@@ -125,17 +140,17 @@ int main(int argc, const char *argv[])
sources.init(config, ctx, dist, shotNumber);
HOST_PRINT(comm, "Start time stepping for shot " << shotNumber + 1 << " of " << sources.getNumShots() << "\n"
<< "Total Number of time steps: " << tEnd << "\n");
<< "Total Number of time steps: " << tStepEnd << "\n");
wavefields->resetWavefields();
start_t = common::Walltime::get();
for (t = 0; t < tEnd; t++) {
for (IndexType tStep = 0; tStep < tStepEnd; tStep++) {
solver->run(receivers, sources, *model, *wavefields, *derivatives, t, t+1, config.get<ValueType>("DT"));
solver->run(receivers, sources, *model, *wavefields, *derivatives, tStep, tStep+1, config.get<ValueType>("DT"));
if (t % timeStepsBetweenSnapshots == 0) {
wavefields->writeSnapshot(t,partitionedOut);
if (config.get<bool>("saveSnapshots") == 1 && tStep >= firstSnapshot && tStep <= lastSnapshot && (tStep-firstSnapshot)%incSnapshot == 0) {
wavefields->writeSnapshot(config.get<std::string>("WavefieldFileName"),tStep,partitionedOut);
}
}
......
......@@ -35,9 +35,9 @@ void KITGPI::Wavefields::Wavefields<ValueType>::initWavefield(scai::lama::DenseV
\param t Timestep
*/
template <typename ValueType>
void KITGPI::Wavefields::Wavefields<ValueType>::writeWavefield(scai::lama::DenseVector<ValueType> &vector, std::string vectorName, std::string type, IndexType t, IndexType partitionedOut)
void KITGPI::Wavefields::Wavefields<ValueType>::writeWavefield(scai::lama::DenseVector<ValueType> &vector, std::string component, std::string fileBaseName, IndexType t, IndexType partitionedOut)
{
std::string fileName = "wavefields/wavefield" + type + "." + vectorName + "." + std::to_string(static_cast<long long>(t)) + ".mtx";
std::string fileName = fileBaseName + "." + component + "." + std::to_string(static_cast<long long>(t)) + ".mtx";
PartitionedInOut::PartitionedInOut<ValueType> partitionOut;
......
......@@ -62,8 +62,8 @@ namespace KITGPI
//! \brief Initialization
virtual void init(scai::hmemo::ContextPtr ctx, scai::dmemo::DistributionPtr dist) = 0;
virtual void write(std::string type, scai::IndexType t, scai::IndexType partitionedOut) = 0;
virtual void writeSnapshot(scai::IndexType t, scai::IndexType partitionedOut) = 0;
virtual void write(std::string baseName, std::string type, scai::IndexType t, scai::IndexType partitionedOut) = 0;
virtual void writeSnapshot(std::string baseName, scai::IndexType t, scai::IndexType partitionedOut) = 0;
//! Operator overloading
virtual void minusAssign(KITGPI::Wavefields::Wavefields<ValueType> &rhs) = 0;
......@@ -79,7 +79,7 @@ namespace KITGPI
protected:
void resetWavefield(scai::lama::DenseVector<ValueType> &vector);
void initWavefield(scai::lama::DenseVector<ValueType> &vector, scai::hmemo::ContextPtr ctx, scai::dmemo::DistributionPtr dist);
void writeWavefield(scai::lama::DenseVector<ValueType> &vector, std::string vectorName, std::string type, scai::IndexType t, scai::IndexType partitionedOut);
void writeWavefield(scai::lama::DenseVector<ValueType> &vector, std::string component, std::string fileBaseName, scai::IndexType t, scai::IndexType partitionedOut);
scai::lama::DenseVector<ValueType> VX; //!< Wavefield for velocity in x
scai::lama::DenseVector<ValueType> VY; //!< Wavefield for velocity in y
......
......@@ -38,11 +38,12 @@ KITGPI::Wavefields::FD2Dacoustic<ValueType>::FD2Dacoustic(scai::hmemo::ContextPt
\param t Current Timestep
*/
template <typename ValueType>
void KITGPI::Wavefields::FD2Dacoustic<ValueType>::write(std::string type, IndexType t, IndexType partitionedOut)
void KITGPI::Wavefields::FD2Dacoustic<ValueType>::write(std::string baseName, std::string type, IndexType t, IndexType partitionedOut)
{
this->writeWavefield(VX, "VX", type, t, partitionedOut);
this->writeWavefield(VY, "VY", type, t, partitionedOut);
this->writeWavefield(P, "P", type, t, partitionedOut);
std::string fileBaseName = baseName + type;
this->writeWavefield(VX, "VX", fileBaseName, t, partitionedOut);
this->writeWavefield(VY, "VY", fileBaseName, t, partitionedOut);
this->writeWavefield(P, "P", fileBaseName, t, partitionedOut);
}
/*! \brief Wrapper Function to Write Snapshot of the Wavefield
......@@ -51,9 +52,9 @@ void KITGPI::Wavefields::FD2Dacoustic<ValueType>::write(std::string type, IndexT
\param t Current Timestep
*/
template <typename ValueType>
void KITGPI::Wavefields::FD2Dacoustic<ValueType>::writeSnapshot(IndexType t, IndexType partitionedOut)
void KITGPI::Wavefields::FD2Dacoustic<ValueType>::writeSnapshot(std::string baseName, IndexType t, IndexType partitionedOut)
{
write(type, t, partitionedOut);
write(baseName, type, t, partitionedOut);
}
/*! \brief Set all wavefields to zero.
......
......@@ -58,8 +58,8 @@ namespace KITGPI
void init(scai::hmemo::ContextPtr ctx, scai::dmemo::DistributionPtr dist) override;
void write(std::string type, scai::IndexType t, scai::IndexType partitionedOut) override;
void writeSnapshot(scai::IndexType t, scai::IndexType partitionedOut);
void write(std::string baseName,std::string type, scai::IndexType t, scai::IndexType partitionedOut) override;
void writeSnapshot(std::string baseName,scai::IndexType t, scai::IndexType partitionedOut);
void minusAssign(KITGPI::Wavefields::Wavefields<ValueType> &rhs);
void plusAssign(KITGPI::Wavefields::Wavefields<ValueType> &rhs);
......
......@@ -40,13 +40,14 @@ void KITGPI::Wavefields::FD2Delastic<ValueType>::init(scai::hmemo::ContextPtr ct
\param t Current Timestep
*/
template <typename ValueType>
void KITGPI::Wavefields::FD2Delastic<ValueType>::write(std::string type, IndexType t, IndexType partitionedOut)
void KITGPI::Wavefields::FD2Delastic<ValueType>::write(std::string baseName,std::string type, IndexType t, IndexType partitionedOut)
{
this->writeWavefield(VX, "VX", type, t, partitionedOut);
this->writeWavefield(VY, "VY", type, t, partitionedOut);
this->writeWavefield(Sxx, "Sxx", type, t, partitionedOut);
this->writeWavefield(Syy, "Syy", type, t, partitionedOut);
this->writeWavefield(Sxy, "Sxy", type, t, partitionedOut);
std::string fileBaseName = baseName + type;
this->writeWavefield(VX, "VX", fileBaseName, t, partitionedOut);
this->writeWavefield(VY, "VY", fileBaseName, t, partitionedOut);
this->writeWavefield(Sxx, "Sxx", fileBaseName, t, partitionedOut);
this->writeWavefield(Syy, "Syy", fileBaseName, t, partitionedOut);
this->writeWavefield(Sxy, "Sxy", fileBaseName, t, partitionedOut);
}
/*! \brief Wrapper Function to Write Snapshot of the Wavefield
......@@ -55,9 +56,9 @@ void KITGPI::Wavefields::FD2Delastic<ValueType>::write(std::string type, IndexTy
\param t Current Timestep
*/
template <typename ValueType>
void KITGPI::Wavefields::FD2Delastic<ValueType>::writeSnapshot(IndexType t, IndexType partitionedOut)
void KITGPI::Wavefields::FD2Delastic<ValueType>::writeSnapshot(std::string baseName,IndexType t, IndexType partitionedOut)
{
write(type, t, partitionedOut);
write(baseName, type, t, partitionedOut);
}
/*! \brief Set all wavefields to zero.
......
......@@ -56,8 +56,8 @@ namespace KITGPI
KITGPI::Wavefields::FD2Delastic<ValueType> operator*(KITGPI::Wavefields::FD2Delastic<ValueType> rhs);
KITGPI::Wavefields::FD2Delastic<ValueType> operator*=(KITGPI::Wavefields::FD2Delastic<ValueType> rhs);
void write(std::string type, scai::IndexType t, scai::IndexType partitionedOut) override;
void writeSnapshot(scai::IndexType t, scai::IndexType partitionedOut);
void write(std::string baseName,std::string type, scai::IndexType t, scai::IndexType partitionedOut) override;
void writeSnapshot(std::string baseName,scai::IndexType t, scai::IndexType partitionedOut);
void minusAssign(KITGPI::Wavefields::Wavefields<ValueType> &rhs);
void plusAssign(KITGPI::Wavefields::Wavefields<ValueType> &rhs);
......
......@@ -43,16 +43,14 @@ void KITGPI::Wavefields::FD2Dvisco<ValueType>::init(scai::hmemo::ContextPtr ctx,
\param t Current Timestep
*/
template <typename ValueType>
void KITGPI::Wavefields::FD2Dvisco<ValueType>::write(std::string type, IndexType t, IndexType partitionedOut)
void KITGPI::Wavefields::FD2Dvisco<ValueType>::write(std::string baseName,std::string type, IndexType t, IndexType partitionedOut)
{
this->writeWavefield(VX, "VX", type, t, partitionedOut);
this->writeWavefield(VY, "VY", type, t, partitionedOut);
this->writeWavefield(Sxx, "Sxx", type, t, partitionedOut);
this->writeWavefield(Syy, "Syy", type, t, partitionedOut);
this->writeWavefield(Sxy, "Sxy", type, t, partitionedOut);
this->writeWavefield(Rxx, "Rxx", type, t, partitionedOut);
this->writeWavefield(Ryy, "Ryy", type, t, partitionedOut);
this->writeWavefield(Rxy, "Rxy", type, t, partitionedOut);
std::string fileBaseName = baseName + type;
this->writeWavefield(VX, "VX", fileBaseName, t, partitionedOut);
this->writeWavefield(VY, "VY", fileBaseName, t, partitionedOut);
this->writeWavefield(Sxx, "Sxx", fileBaseName, t, partitionedOut);
this->writeWavefield(Syy, "Syy", fileBaseName, t, partitionedOut);
this->writeWavefield(Sxy, "Sxy", fileBaseName, t, partitionedOut);
}
/*! \brief Wrapper Function to Write Snapshot of the Wavefield
......@@ -61,9 +59,9 @@ void KITGPI::Wavefields::FD2Dvisco<ValueType>::write(std::string type, IndexType
\param t Current Timestep
*/
template <typename ValueType>
void KITGPI::Wavefields::FD2Dvisco<ValueType>::writeSnapshot(IndexType t, IndexType partitionedOut)
void KITGPI::Wavefields::FD2Dvisco<ValueType>::writeSnapshot(std::string baseName,IndexType t, IndexType partitionedOut)
{
write(type, t, partitionedOut);
write(baseName, type, t, partitionedOut);
}
/*! \brief Set all wavefields to zero.
......
......@@ -53,8 +53,8 @@ namespace KITGPI
KITGPI::Wavefields::FD2Dvisco<ValueType> operator*(KITGPI::Wavefields::FD2Dvisco<ValueType> rhs);
KITGPI::Wavefields::FD2Dvisco<ValueType> operator*=(KITGPI::Wavefields::FD2Dvisco<ValueType> rhs);
void write(std::string type, scai::IndexType t, scai::IndexType partitionedOut) override;
void writeSnapshot(scai::IndexType t, scai::IndexType partitionedOut);
void write(std::string baseName,std::string type, scai::IndexType t, scai::IndexType partitionedOut) override;
void writeSnapshot(std::string baseName,scai::IndexType t, scai::IndexType partitionedOut);
void minusAssign(KITGPI::Wavefields::Wavefields<ValueType> &rhs);
void plusAssign(KITGPI::Wavefields::Wavefields<ValueType> &rhs);
......
......@@ -39,12 +39,13 @@ void KITGPI::Wavefields::FD3Dacoustic<ValueType>::init(scai::hmemo::ContextPtr c
\param t Current Timestep
*/
template <typename ValueType>
void KITGPI::Wavefields::FD3Dacoustic<ValueType>::write(std::string type, IndexType t, IndexType partitionedOut)
void KITGPI::Wavefields::FD3Dacoustic<ValueType>::write(std::string baseName,std::string type, IndexType t, IndexType partitionedOut)
{
this->writeWavefield(VX, "VX", type, t, partitionedOut);
this->writeWavefield(VY, "VY", type, t, partitionedOut);
this->writeWavefield(VZ, "VZ", type, t, partitionedOut);
this->writeWavefield(P, "P", type, t, partitionedOut);
std::string fileBaseName = baseName + type;
this->writeWavefield(VX, "VX", fileBaseName, t, partitionedOut);
this->writeWavefield(VY, "VY", fileBaseName, t, partitionedOut);
this->writeWavefield(VZ, "VZ", fileBaseName, t, partitionedOut);
this->writeWavefield(P, "P", fileBaseName, t, partitionedOut);
}
/*! \brief Wrapper Function to Write Snapshot of the Wavefield
......@@ -53,9 +54,9 @@ void KITGPI::Wavefields::FD3Dacoustic<ValueType>::write(std::string type, IndexT
\param t Current Timestep
*/
template <typename ValueType>
void KITGPI::Wavefields::FD3Dacoustic<ValueType>::writeSnapshot(IndexType t, IndexType partitionedOut)
void KITGPI::Wavefields::FD3Dacoustic<ValueType>::writeSnapshot(std::string baseName,IndexType t, IndexType partitionedOut)
{
write(type, t, partitionedOut);
write(baseName, type, t, partitionedOut);
}
/*! \brief Set all wavefields to zero.
......
......@@ -57,8 +57,8 @@ namespace KITGPI
KITGPI::Wavefields::FD3Dacoustic<ValueType> operator*(KITGPI::Wavefields::FD3Dacoustic<ValueType> rhs);
KITGPI::Wavefields::FD3Dacoustic<ValueType> operator*=(KITGPI::Wavefields::FD3Dacoustic<ValueType> rhs);
void write(std::string type, scai::IndexType t, scai::IndexType partitionedOut) override;
void writeSnapshot(scai::IndexType t, scai::IndexType partitionedOut);
void write(std::string baseName,std::string type, scai::IndexType t, scai::IndexType partitionedOut) override;
void writeSnapshot(std::string baseName,scai::IndexType t, scai::IndexType partitionedOut);
void minusAssign(KITGPI::Wavefields::Wavefields<ValueType> &rhs);
void plusAssign(KITGPI::Wavefields::Wavefields<ValueType> &rhs);
......
Supports Markdown
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