Line data Source code
1 : // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 : // SPDX-License-Identifier: Apache-2.0
3 :
4 : #include "gridfunction.hpp"
5 :
6 : #include "fem/fespace.hpp"
7 :
8 : namespace palace
9 : {
10 :
11 34 : GridFunction::GridFunction(mfem::ParFiniteElementSpace &fespace, bool complex)
12 34 : : gfr(&fespace)
13 : {
14 34 : if (complex)
15 : {
16 16 : gfi.SetSpace(&fespace);
17 : }
18 34 : }
19 :
20 34 : GridFunction::GridFunction(FiniteElementSpace &fespace, bool complex)
21 34 : : GridFunction(fespace.Get(), complex)
22 : {
23 34 : }
24 :
25 0 : GridFunction &GridFunction::operator=(std::complex<double> s)
26 : {
27 : Real() = s.real();
28 0 : if (HasImag())
29 : {
30 : Imag() = s.imag();
31 : }
32 : else
33 : {
34 : MFEM_ASSERT(
35 : s.imag() == 0.0,
36 : "Cannot assign complex scalar to a non-complex-valued GridFunction object!");
37 : }
38 0 : return *this;
39 : }
40 :
41 0 : GridFunction &GridFunction::operator*=(double s)
42 : {
43 0 : Real() *= s;
44 0 : if (HasImag())
45 : {
46 0 : Imag() *= s;
47 : }
48 0 : return *this;
49 : }
50 :
51 0 : void GridFunction::Update()
52 : {
53 0 : Real().Update();
54 0 : if (HasImag())
55 : {
56 0 : Imag().Update();
57 : }
58 0 : }
59 :
60 : } // namespace palace
|