Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
fwi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gmsh
fwi
Commits
cc334983
Commit
cc334983
authored
3 years ago
by
Xavier Adriaens
Browse files
Options
Downloads
Patches
Plain Diff
Auxilary field final
parent
cd7726e0
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/wave/element.cpp
+57
-0
57 additions, 0 deletions
common/wave/element.cpp
common/wave/element.h
+13
-58
13 additions, 58 deletions
common/wave/element.h
common/wave/equation/equation.cpp
+28
-26
28 additions, 26 deletions
common/wave/equation/equation.cpp
with
98 additions
and
84 deletions
common/wave/element.cpp
0 → 100644
+
57
−
0
View file @
cc334983
//GmshFWI Library
#include
"element.h"
/*
* WaveMultiField
*/
template
<
Physic
T_Physic
>
void
WaveMultiField
<
T_Physic
>::
initializeField
(
const
WaveField
<
T_Physic
>&
field
)
{
_field
=
field
;
for
(
auto
it
=
_dofValues
.
begin
();
it
!=
_dofValues
.
end
();
it
++
)
{
it
->
resize
(
_field
.
numberOfDofs
());
}
_isInitialized
=
true
;
}
template
<
Physic
T_Physic
>
const
WaveField
<
T_Physic
>&
WaveMultiField
<
T_Physic
>::
operator
[](
const
unsigned
int
index
)
const
{
_field
.
setAllVector
(
_dofValues
[
index
],
gmshfem
::
dofs
::
RawOrder
::
Hash
);
return
_field
;
}
template
<
Physic
T_Physic
>
void
WaveMultiField
<
T_Physic
>::
setValues
(
const
unsigned
int
index
,
gmshfem
::
algebra
::
Vector
<
std
::
complex
<
double
>
>
&
vector
)
{
_dofValues
[
index
]
=
std
::
move
(
vector
);
}
template
<
Physic
T_Physic
>
void
WaveMultiField
<
T_Physic
>::
write
(
std
::
string
name
)
const
{
for
(
unsigned
int
s
=
0
;
s
<
size
();
s
++
)
{
(
*
this
)[
s
].
write
(
name
+
"s"
+
std
::
to_string
(
s
));
}
}
/*
* WaveAuxilaryField
*/
template
<
Physic
T_Physic
>
void
WaveAuxilaryField
<
T_Physic
>::
assignValues
(
const
std
::
vector
<
std
::
complex
<
double
>
>
&
values
)
{
unsigned
int
i
=
0
;
for
(
auto
it
=
_wmf
->
_field
.
begin
();
it
!=
_wmf
->
_field
.
end
();
it
++
)
{
if
(
it
->
first
->
type
()
==
gmshfem
::
dofs
::
Type
::
Unknown
)
{
_wmf
->
_dofValues
[
_index
][
i
++
]
=
values
[
it
->
first
->
numDof
()
-
1
];
}
}
}
template
class
WaveMultiField
<
Physic
::
acoustic
>;
template
class
WaveAuxilaryField
<
Physic
::
acoustic
>;
This diff is collapsed.
Click to expand it.
common/wave/element.h
+
13
−
58
View file @
cc334983
...
@@ -6,70 +6,34 @@
...
@@ -6,70 +6,34 @@
#include
"../../specific/wave/element.h"
#include
"../../specific/wave/element.h"
#include
"../configuration.h"
#include
"../configuration.h"
//Forward declaration
template
<
Physic
T_Physic
>
class
WaveAuxilaryField
;
/*
/*
* WaveMultiField
* WaveMultiField
*/
*/
template
<
Physic
T_Physic
>
template
<
Physic
T_Physic
>
class
WaveMultiField
class
WaveMultiField
{
{
p
ublic
:
p
rivate
:
mutable
WaveField
<
T_Physic
>
_field
;
mutable
WaveField
<
T_Physic
>
_field
;
bool
_isInitialized
;
bool
_isInitialized
;
std
::
vector
<
gmshfem
::
algebra
::
Vector
<
std
::
complex
<
double
>
>
>
_dofValues
;
std
::
vector
<
gmshfem
::
algebra
::
Vector
<
std
::
complex
<
double
>
>
>
_dofValues
;
public:
WaveMultiField
(
unsigned
int
n
)
:
_field
(),
_isInitialized
(
false
),
_dofValues
(
n
)
{};
WaveMultiField
(
unsigned
int
n
)
:
_field
(),
_isInitialized
(
false
),
_dofValues
(
n
)
{};
void
setField
(
const
WaveField
<
T_Physic
>&
field
)
void
initializeField
(
const
WaveField
<
T_Physic
>&
field
);
{
_field
=
field
;
for
(
auto
it
=
_dofValues
.
begin
();
it
!=
_dofValues
.
end
();
it
++
)
{
it
->
resize
(
_field
.
numberOfDofs
());
}
_isInitialized
=
true
;
};
bool
isInitialized
()
const
{
return
_isInitialized
;};
bool
isInitialized
()
const
{
return
_isInitialized
;};
unsigned
int
size
()
const
unsigned
int
size
()
const
{
return
_dofValues
.
size
();};
{
return
_dofValues
.
size
();
}
const
WaveField
<
T_Physic
>
&
operator
[](
const
unsigned
int
index
)
const
const
WaveField
<
T_Physic
>
&
operator
[](
const
unsigned
int
index
)
const
;
{
_field
.
setAllVector
(
_dofValues
[
index
],
gmshfem
::
dofs
::
RawOrder
::
Hash
);
return
_field
;
}
/*
void
setValues
(
const
unsigned
int
index
,
gmshfem
::
algebra
::
Vector
<
std
::
complex
<
double
>
>
&
vector
);
void setDofs(const std::vector< gmshfem::dofs::RawDof > &dofs)
{
_field->setAllDofVector(dofs, false);
}
*/
void
setValues
(
const
unsigned
int
index
,
gmshfem
::
algebra
::
Vector
<
std
::
complex
<
double
>
>
&
vector
)
void
write
(
std
::
string
name
)
const
;
{
_dofValues
[
index
]
=
std
::
move
(
vector
);
}
/*
std::vector< gmshfem::algebra::Vector< std::complex< double > > >::const_iterator begin() const
{
return _dofValues.begin();
}
std::vector< gmshfem::algebra::Vector< std::complex< double > > >::const_iterator end() const
friend
class
WaveAuxilaryField
<
T_Physic
>
;
{
return _dofValues.end();
}
*/
void
write
(
std
::
string
name
)
const
{
for
(
unsigned
int
s
=
0
;
s
<
size
();
s
++
)
{
(
*
this
)[
s
].
write
(
name
+
"s"
+
std
::
to_string
(
s
));
}
};
};
};
/*
/*
...
@@ -85,17 +49,8 @@ public:
...
@@ -85,17 +49,8 @@ public:
WaveAuxilaryField
(
std
::
string
name
,
gmshfem
::
domain
::
Domain
domain
,
std
::
string
gmodel
,
const
wave
::
Discretization
<
T_Physic
>&
w_discret
)
:
WaveField
<
T_Physic
>
(
name
,
domain
,
gmodel
,
w_discret
),
_wmf
(
nullptr
),
_index
(
0
)
{};
WaveAuxilaryField
(
std
::
string
name
,
gmshfem
::
domain
::
Domain
domain
,
std
::
string
gmodel
,
const
wave
::
Discretization
<
T_Physic
>&
w_discret
)
:
WaveField
<
T_Physic
>
(
name
,
domain
,
gmodel
,
w_discret
),
_wmf
(
nullptr
),
_index
(
0
)
{};
void
setField
(
WaveMultiField
<
T_Physic
>*
wmf
){
_wmf
=
wmf
;};
void
setField
(
WaveMultiField
<
T_Physic
>*
wmf
){
_wmf
=
wmf
;};
void
setIndex
(
unsigned
int
index
){
_index
=
index
;};
void
setIndex
(
unsigned
int
index
){
_index
=
index
;};
virtual
void
assignValues
(
const
std
::
vector
<
std
::
complex
<
double
>
>
&
values
)
override
virtual
void
assignValues
(
const
std
::
vector
<
std
::
complex
<
double
>
>
&
values
)
override
;
{
unsigned
int
i
=
0
;
for
(
auto
it
=
_wmf
->
_field
.
begin
();
it
!=
_wmf
->
_field
.
end
();
it
++
)
{
if
(
it
->
first
->
type
()
==
gmshfem
::
dofs
::
Type
::
Unknown
)
{
_wmf
->
_dofValues
[
_index
][
i
++
]
=
values
[
it
->
first
->
numDof
()
-
1
];
}
}
};
};
};
#endif // H_COMMON_WAVE_ELEMENT
#endif // H_COMMON_WAVE_ELEMENT
This diff is collapsed.
Click to expand it.
common/wave/equation/equation.cpp
+
28
−
26
View file @
cc334983
...
@@ -104,7 +104,7 @@ DifferentialEquationInterface<T_Physic>::updateWithSystem(WaveMultiField<T_Physi
...
@@ -104,7 +104,7 @@ DifferentialEquationInterface<T_Physic>::updateWithSystem(WaveMultiField<T_Physi
_formulation
.
removeTerms
();
_formulation
.
removeTerms
();
}
}
if
(
!
output
.
isInitialized
()){
output
.
set
Field
(
_v
);};
if
(
!
output
.
isInitialized
()){
output
.
initialize
Field
(
_v
);};
_v
.
setField
(
&
output
);
_v
.
setField
(
&
output
);
for
(
unsigned
int
s
=
0
;
s
<
_config
->
ns
();
s
++
)
for
(
unsigned
int
s
=
0
;
s
<
_config
->
ns
();
s
++
)
...
@@ -178,31 +178,33 @@ const WaveField<T_Physic>& DifferentialEquationInterface<T_Physic>::updateWithGr
...
@@ -178,31 +178,33 @@ const WaveField<T_Physic>& DifferentialEquationInterface<T_Physic>::updateWithGr
template
<
Physic
T_Physic
>
template
<
Physic
T_Physic
>
void
DifferentialEquationInterface
<
T_Physic
>::
updateGreen
(
const
ModelStateEvaluator
&
m
,
const
std
::
vector
<
unsigned
int
>&
p_idx
)
void
DifferentialEquationInterface
<
T_Physic
>::
updateGreen
(
const
ModelStateEvaluator
&
m
,
const
std
::
vector
<
unsigned
int
>&
p_idx
)
{
{
// if(!_systemIsUpToDate)
if
(
!
_systemIsUpToDate
)
// {
{
// _formulation.removeSystem();
_formulation
.
removeSystem
();
// _formulation.initSystem();
_formulation
.
initSystem
();
//
// _systemIsFactorized=false;
_systemIsFactorized
=
false
;
// setLHS(m);
setLHS
(
m
);
// _formulation.pre();
_formulation
.
pre
();
// _formulation.assemble();
_formulation
.
assemble
();
// _systemIsUpToDate=true;
_systemIsUpToDate
=
true
;
// _formulation.removeTerms();
_formulation
.
removeTerms
();
// }
}
//
// for (auto it = p_idx.begin(); it != p_idx.end(); it++)
if
(
!
_g
.
isInitialized
()){
_g
.
initializeField
(
_v
);};
// {
_v
.
setField
(
&
_g
);
// setGreenRHS(*it);
// _formulation.assemble();
for
(
auto
it
=
p_idx
.
begin
();
it
!=
p_idx
.
end
();
it
++
)
// _formulation.removeTerms();
{
//
_v
.
setIndex
(
*
it
);
// _formulation.solve(_systemIsFactorized);
setGreenRHS
(
*
it
);
// _systemIsFactorized=true;
_formulation
.
assemble
();
// _formulation.setRHSToZero();
_formulation
.
removeTerms
();
// _g[*it] = _v;
// //_v.getVector(_dofg[*it]);
_formulation
.
solve
(
_systemIsFactorized
);
// }
_systemIsFactorized
=
true
;
_formulation
.
setRHSToZero
();
}
}
}
template
<
Physic
T_Physic
>
template
<
Physic
T_Physic
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment